简体   繁体   English

如何还原在gitk树中引起合并的提交?

[英]how to revert a commit that caused a merge in the gitk tree?

one of my team mates made a commit and pushed it. 我的一个队友做出了承诺,并予以推动。 It caused a merge in the git tree. 它在git树中引起了合并。 problem is that the code is tagged and this push makes it look like the commit is before the tag. 问题在于代码已被标记,并且这种推送使它看起来像是在标记之前进行提交。 Actual case is that the commit is after the tag. 实际情况是提交在标记之后。 There are other pushes after this merge. 合并之后还有其他推送。 Now, I want to completely remove this commit from the gitk tree. 现在,我想从gitk树中完全删除此提交。 How can I do that? 我怎样才能做到这一点?

There are no way to change the look of the gitk tree without rewriting the history and then pushing it with git push -f ... . 如果不重写历史记录,然后再使用git push -f ...将其git push -f ...就无法更改gitk树的外观。 If you want to revert the merge commit itself (the changes, that was merged into your branch) you can use git revert <commit-hash> as you would do with a normal commit. 如果您想还原合并提交本身(所做的更改,这些更改已合并到您的分支中),则可以像普通提交一样使用git revert <commit-hash> It would create a new commit reverting the changes from the merge commit. 它将创建一个新的提交,以还原合并提交中的更改。

The easy way to remove the merge commit from the tree is 从树中删除合并提交的简单方法是

  • git checkout -b TESTING (Create a temporary branch to test with) git checkout -b TESTING (创建一个临时分支进行测试)
  • git branch TMP <commit-on-YOUR-branch-just-before-merge>
  • git rebase TMP -i

You will have to remove in the editor all commits from the other branch that was merged into your branch. 您将必须在编辑器中删除合并到您分支中的另一个分支中的所有提交。 If everything does well: 如果一切顺利:

  • git branch -f YOUR_BRANCH TESTING
  • git push -f ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM