第一次首先关联服务器地址git@github.com:michaelliao/learngit.git为服务器地址。代码如下:
git remote add origin git@github.com:michaelliao/learngit.git
若是这个不能使用,请使用下面指令
$ git push --set-upstream git@github.com:michaelliao/learngit.git master
下一步,git push -u origin master 就可以把本地库的所有内容推送到远程库上:如下
$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
以后再次推送到服务 直接 git push origin master 远程库的名字就是origin
,这是Git默认的叫法
推送分支到服务器指令为 git push -u origin xxx_test xxx_test为分支名