git push时的错误

git push时出现

$ git push tt ycv1
error: src refspec ycv1 does not match any
error: failed to push some refs to 'xxxx'

当将本地分支 push 到远端同名的分支时,branchname 只需要写一个分支名就可以(如直接克隆远程分支后修改再push)
但当要 push 到的远端分支名不同于本地分支名时,需要使用
git push origin [本地分支名:远端分支名] .
但是又出现

$ git push tt master:ycv1
To https://gitee.com/...
 ! [rejected]        master -> ycv1 (fetch first)
error: failed to push some refs to 'https://gitee.com/...'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因:其他地方向同一远端库推送了代码,导致本地不是最新的.
方法一:git pull 一下即可,如果进入MERGE_MSG(linux)界面,可以ESC+:wq退出,然后git push 远程分支(但不建议这样做)
方法二:git fetch + git merge + git push 远程分支(建议使用)
然后又使用$ git pull tt ycv1出现fatal: refusing to merge unrelated histories
这是因为两个分支没有取得关系,
在你操作命令后面加--allow-unrelated-histories,例如$ git pull tt ycv1 --allow-unrelated-histories然后$ git push tt master:ycv1成功!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值