Github:还原后忽略更改(git cherrypick,git rebase) [英] Github: Changes ignored after revert (git cherrypick, git rebase)

查看:178
本文介绍了Github:还原后忽略更改(git cherrypick,git rebase)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个分支AB

(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆