pull rebase后Git推分支错误 [英] Git push branch error after pull rebase
问题描述
步骤1. git pull --rebase
步骤2: git push来源my_branch
我得到推送失败错误。如果我删除远程分支后推分支,那么没有错误。
谢谢
假设两个分支的基础是不同的,那么在Git中重新分支一个分支可能涉及重写这个分支的历史。解决方案
从你告诉我们的看来,你似乎是在不同的分支上重新设计的。在你的情况下,很可能你的 my_branch
被重写,这意味着你不能简单地推送到远程。
为了解决这个问题,您可以通过以下方式强制推送分支: code>
然而,如果不同分支上的rebase是无意的,您可能不希望这样做。
相反,尝试用这种方式重新绑定:
git pull --rebase origin my_branch
#解决合并冲突,如果有任何
git push origin my_branch
常规警告:
强制推送公共分支通常是一个坏主意,因为它会为共享该分支的每个人带来问题。如果您当前的工作流程涉及这样做,您可能需要重新考虑。
step 1. git pull --rebase
step 2: git push origin my_branch
I get push failed error. If I push branch after removing remote branch then no error.
Question, how to push branch after pull rebase?
Thanks
Rebasing a branch in Git may involve rewriting the history of that branch, assuming that the bases of the two branches were different. From what you told us, it seems that you rebased on a different branch. Most likely, in your case, your my_branch
was rewritten, which means you cannot simply push to the remote.
To get around this, you can force push your branch via:
git push --force origin my_branch
However, you might not want to do this if the rebase on a different branch were unintentional.
Instead, try rebasing this way:
git pull --rebase origin my_branch
# resolve merge conflicts, if any
git push origin my_branch
General warning:
Force pushing a public shared branch is usually a bad idea, because it causes problems for everyone who shares that branch. If your current workflow involves doing this, you might want to reconsider.
这篇关于pull rebase后Git推分支错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!