Github:还原后忽略更改(git cherrypick,git rebase) [英] Github: Changes ignored after revert (git cherrypick, git rebase)
问题描述
假设我有两个分支A
和B
(A)--------(A+B)--------------(A+B+R)
\ / merge \ revert /
\ / \ /
(B)----(B+) (R)----
首先,我将分支B
合并到A
,
然后,我使用GitHub的还原功能还原了合并请求.
First, I merged branch B
to A
,
Then I reverted the merge request with GitHub's revert feature.
现在,当我在分支B
上修复一些代码并需要再次合并到A
时,几乎所有更改(我所修复的新更改除外)都将被忽略.如何再次获得更改?
Now when I fix some code on branch B
and need to merge to A
again, almost all changes (except the new one that I fix) are ignored. How can I get the changes again?
推荐答案
在此处阅读如何重置"您的更改 如何将HEAD移回先前的位置? (独立的头)
Read here how to "reset" your changes How to move HEAD back to a previous location? (Detached head)
一旦有了所需的代码,便将其再次推送到存储库中.由于您执行了还原操作而不是重设操作,因此您可以简单地推送代码而不会出现任何问题.
Once you have the code you want it push it again to the repository. Since you did a revert and not reset you can simply push the code without any problem.
如果您已完成reset
并且希望更新远程分支,则必须force
使用git push -f origin master
进行推送,这将导致重新建立基础,这也将影响您的所有同事. /p>
If you have done a reset
and you wish to update the remote branch you will have to force
push with the git push -f origin master
and this will result in a rebase which will affect all your co workers as well.
如何再次获得更改?
How can i get the changes again?
git cherry-pick
最简单的方法是简单地执行git cherry-pick
再次选择所需的提交到您的分支.
git cherry-pick
The easiest way is simply to do a git cherry-pick
to pick the desired commit back to your branch again.
# Find out the range of commits you wish to re-add to your branch.
# then use cherry-pick to add them back to the branch
git cherry-pick start..end
# If you wish to include the start commit as well add the ^
# This will result in a cherry-pick of the start commit included as well
git cherry-pick start^..end
git rebase --onto
(Carefull =变基)
git rebase --onto
(Carefull = rebase)
# reset it to the start commit
git reset --hard start
# rebase every commit after b and transplant it onto a
git rebase --onto commit1 commit2 commit3 ... commitN
这篇关于Github:还原后忽略更改(git cherrypick,git rebase)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!