Create a new repo
”按钮,创建一个新的仓库:
Repository name填入learngit
,其他保持默认设置,点击“Create repository
”按钮,就成功地创建了一个新的Git仓库:learngit
仓库下运行命令:
$ git remote add origin git@github.com:用户名/learngit.git
origin
这个名字一看就知道是远程库。
$ git push -u origin master
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (20/20), 1.64 KiB | 560.00 KiB/s, done.
Total 20 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To github.com:michaelliao/learngit.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
git push
命令,实际上是把当前分支master推送到远程。
master
分支时,加上了-u
参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
$ git push origin master
The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?
Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
git remote add origin git@server-name:path/repo-name.git
;
git push -u origin master
第一次推送master
分支的所有内容;
git push origin master
推送最新修改;