简体   繁体   English

GIT:如何在还原合并后从分支中提取更改

[英]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.

相关问题 git:合并分支中的更改,该分支还原了先前的合并 - git: merge changes from a branch that reverted a previous merge 成功的git merge into master不会在GitHub上显示任何更改,也不会在master分支中显示git之后 - Successful git merge into master is not showing any changes on GitHub or after git pull from master branch 从分支上创建新的拉取请求恢复到开发分支的更改 - Create new Pull Request from a branch on a reverted changes to develop branch GIT merge develop into feature branch -- 同一个分支被合并和恢复后 - GIT merge develop into feature branch -- after the same branch was merged and reverted 如何创建一个从master恢复的新分支,然后在恢复后的新提交后使用该分支进行pull请求? - How to make a new branch that is reverted from master, and then make pull requested with the branch after new commit after reversion? git merge 恢复但需要更改 - git merge reverted but the changes needed git中合并后分支的变化 - Changes in branch after merge in git 重新合并在Github上将更改从分支还原到主服务器? - Re-merge reverted changes from a branch into master on Github? 如何通过git将更改从一个分支拉到另一个分支 - How to pull changes from one branch to another branch through git Git拉取请求:从分支合并到另一个空分支-选定分支之间没有更改 - Git Pull Request: Merge from branch into another empty branch - No changes between selected branches
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM