git push命令

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(本地分支)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值