git push命令
标准的git push
:
$ git push <远程主机名> <本地分支名>:<远程分支名>
$ git push <远程主机名> :<远程分支名> //删除远程分支 如: git push origin :hotfix
创建一个裸仓库
$ git init --bare repo/repo-demo.git
创建一个带工作区的仓库
$ cd demo
$ git init
尝试向裸仓库提交
root@localhost:demo# git push /home/tom/git-learn/repo/repo-demo.git master:master
error: src refspec master does not match any.
error: failed to push some refs to '/home/tom/git-learn/repo/repo-demo.git'
原因:工作区的本地仓库为空
$ git add README.MD
$ git commit -m 'init'
继续提交:
root@localhost:demo# git push /home/tom/git-learn/repo/repo-demo.git master:master
Counting objects: 3, done.
Writing objects: 100% (3/3), 199 bytes | 199.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /home/tom/git-learn/repo/repo-demo.git
* [new branch] master -> master
root@apps-97bf6bdc9-5ggjg:/home/tom/git-learn/demo# git log
尝试拉取更新
git: There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
原因:本地分支没有和远程分支建立连接关系,git不能明确到远程的哪个分支更新数据
解决方案:
git branch --set-upstream-to=origin/master(远程分支) master(本地分支)