[英]GIT: How to pull changes from branch after a reverted merge
I hope the title is not very confusing. 我希望标题不是很混乱。
History (aka What I did wrong): 历史(又名我做错了):
Let's say there are two branches, master and feature. 假设有两个分支,主要和特征。 Feature is a branch where I keep a longer feature project and from time to time I use git pull origin master on that branch to stay updated with changes in main code.
功能是一个分支,我保留一个较长的功能项目,并不时在该分支上使用git pull origin master来保持更新主代码的更新。
I accidentally merged and pushed feature into master. 我偶然合并并将功能推入主人。
It was nowhere near ready, so I tried to revert it. 它还没有准备好,所以我试图恢复它。 I tried following: http://sethrobertson.github.io/GitFixUm/fixup.html#pushed_new_merge But I guess I did it wrong.
我试过以下: http : //sethrobertson.github.io/GitFixUm/fixup.html#pushed_new_merge但我想我做错了。 I used: git revert then commited the revert and pushed it.
我用过:git revert然后提交恢复并推送它。 Problem seemed solved - the feature changes where no longer on master.
问题似乎已经解决了 - 这个功能在主人不再变化
Now the problem is that when I try to use git pull origin master on feature branch it keeps deleting my files and reverting all changes, as it is merging with the revert-commit. 现在的问题是,当我尝试在功能分支上使用git pull origin master时,它会继续删除我的文件并恢复所有更改,因为它正在与revert-commit合并。 The head of master is way past that revert and I need to pull the changes from newer commits to continue with feature branch.
主人的头是过去的那个恢复,我需要从更新的提交中拉出更改继续功能分支。
I've googled the topic and the most promising answer is this: https://metlos.wordpress.com/2012/01/13/git-merging-after-a-revert/ but here the merge goes other way than I want to (feature to master, i need master to feature). 我用谷歌搜索了这个话题,最有希望的答案是这样的: https : //metlos.wordpress.com/2012/01/13/git-merging-after-a-revert/但这里合并的方式不同于我想要的to(要掌握的功能,我需要掌握功能)。
I am thinking of creating clone branch of master, then applying the instructions from the link on that branch so I can get the results I need, but I am afraid it's a temporary solution I would need to apply anytime I want to pull from master. 我正在考虑创建master的clone分支,然后应用来自该分支上的链接的指令,这样我就可以得到我需要的结果,但是我担心这是一个临时解决方案,我需要随时应用我想要从master中提取。
I tried best for this story not to be chaotic, If something is not understandable I will clarify. 我最好为这个故事不要乱,如果有些事情是不可理解的,我会澄清。
If you have not pushed master branch to a team/public repository and you have no commit after the pull on master, you may do 如果您还没有将master分支推送到团队/公共存储库,并且在掌握了master之后没有提交,那么您可以这样做
git reset --hard **the-commit-before-pulling-feature-branch**
on the master branch. 在主分支上。 This will effectively wipe out the mistake from history and gives a clean history.
这将有效地消除历史上的错误,并提供一个干净的历史。
otherwise, (ie if you have already pushed master to a repo or done more commits on master), you may do 否则,(即如果你已经将master推送到repo或者对master做了更多提交),你可以这样做
git revert **the-revert-commit**
on the feature branch after pulling the master, effectively reverting the revert commit. 拔出主控后在功能分支上,有效恢复恢复提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.