一、需要在github的Account settings中关联本地ssh公钥,方法参考如下网址:
使用HTTPS需要每次输入密码,SSH则不用,但SSH需要配置密钥 。
二、命令行的区别:
1. 采用https:
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/guochy2012/test.git
git push -u origin master
Push an existing repository from the command line
git remote add origin https://github.com/cyrion/test.git
git push origin master
2. 采用SSH:
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:cyrion/test.git
git push -u origin master
Push an existing repository from the command line
git remote add origin git@github.com:cyrion/test.git
git push origin master
补充说明:
把本地库的内容推送到远程,用git push命令,实际上是把当前分支master推送到远程。
当第一次建立远程库,远程库为空时,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令为
git push origin master