Git-Flow undo a finished feature branch

試著忘記壹切 提交于 2019-12-06 01:51:29

问题


What options do you have if you want to "undo" a feature branch? Let's say you add a new feature supercool-feature which you finish (merge into development and delete the feature branch) and then it goes into a release. But then your users really dislike this supercool-feature. How can I undo/rewind/reverse this feature which has been already merged into development and a release?

I'm using SourceTree to do my versioning.


回答1:


Run this command

git revert -m 1 <sha1 of M>

Explanation

Your situation is about as follows:

A-B-----C---D-M     # master
   \         /
    X-Y---Z-        # supercool-feature

A, B, C and D were in your master branch, X, Y and Z in your feature branch. When you did git merge supercool-feature Git created a "merge commit" M for you. This commit encloses all commits from your feature branch as well as possible fixes to fix merge conflicts. So if you revert that one commit, every change from your featurebranch will be gone again.




回答2:


Actually the command is

git revert -m 1 <sha1 of M>

which remove M moving back on branch containing X,Y,Z which is not the mainline 1.



来源:https://stackoverflow.com/questions/16792558/git-flow-undo-a-finished-feature-branch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!