git第一次连接远程仓库

git第一次连接远程仓库

  • 1.第一次git commit
    • 没有设置全局user name 和 email
  • 2.连接远程github仓库
    • push的时候产生问题
    • 添加rsa-public key
    • 导入公钥
    • 测试:

1.第一次git commit

没有设置全局user name 和 email

//随便设置了一个
git config --global user.name "mr"
git config --global user.email "mr"

2.连接远程github仓库

push的时候产生问题

//取消原来的设置
git config --global --unset user.name 
git config --global --unset user.email

//设置自己github上的名称和email
 git config --global user.name "NJUPT-ZhangAn"
 git config --global user.email "[email protected]"

添加rsa-public key

输入:
ssh-keygen -t rsa -C "邮箱"
//以下是显示
Generating public/private rsa key pair.
Enter file in which to save the key (/home/an/.ssh/id_rsa): id_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The key's randomart image is:

导入公钥

将 id_rsa.pub中内容拷贝到github:https://github.com/settings/keys
中.

cat id_rsa.pub//复制粘贴

测试:

设置成ssh客户端:
ssh-agent -s
添加私钥:(这里的路径可能有问题,我的私钥直接在home目录下)
ssh-add ~/.ssh/id_rsa

可以先进行测试这一步.

输入:
ssh -T [email protected] 
显示:
Hi NJUPT-ZhangAn! You've successfully authenticated, but GitHub does not provide shell access.
PUSH:
git push -u origin master

你可能感兴趣的:(Git)