Git在LINUX上安装

2. 设置Git

(1)设置用户名和email。

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

此时,Home目录下会新建一个.gitconfig文件

3. 为GitHub账号添加SSH Keys

以公钥认证方式访问SSH协议的Git服务器时无需输入口令,而且更安全。(访问HTTP协议的Git服务器时,比如提交修改,每次都需要输入口令。)

(1)创建SSH key

$ ssh-keygen -t rsa -C "[email protected]"

系统会提示key的保存位置(一般是~/.ssh目录)和指定口令,保持默认,连续三次回车即可。

(2)Copy SSH Key

然后用vim打开该文件,id_rsa.pub文件内的内容,粘帖到github帐号管理的添加SSH key界面中。

vim ~/.ssh/id_rsa.pub

(3)添加到GitHub

登录github-> Accounting settings图标-> SSH key-> Add SSH key-> 填写SSH key的名称(可以起一个自己容易区分的),然后将拷贝的~/.ssh/id_rsa.pub文件内容粘帖-> add key”按钮添加。

(4)测试

ssh -T [email protected]

4. 为GitHub上的Repository提交修改

(1)git clone已存在GitHub上的Repository。(在新建的~/MyTestFolder目录中)

git clone https://github.com/zhchnchn/ZhchnchnTest.git
 
 
将本地master分支对应远程仓库的master分支,之后可以直接使用git pull 和 git push 
git branch --set-upstream master origin/master
上传代码:git push -u origin master

猜你喜欢

转载自blog.csdn.net/u013120422/article/details/61209277