简体   繁体   中英

How to remove feature branch from develop in Git/Bitbucket

Maybe I have the wrong approach to Git-Flow...

I use Bitbucket (git) with GitFlow workflow.

I would like to know if it's possible to completely remove source changes of a feature branch after a merging with develop branch even after other branch features were merged

Edit: I try to explain better. I don't want to delete a feature branch, I want to remove all the changes brought by the feature branch.

I think that I can revert if my feature-branch is the last operation. But if: - I've done the merge of my feature-branch on develop-branch - other features have merged on develop-branch

and only after this operation I need to remove my first feature without lost any other features, it's possible?

Thanks, Ruggero

In interpret your question so that you want to undo the merge of your featurebranch into develop .

This should be possible using

git checkout develop
git revert mergecommit -m 1

Where mergecommit is the hash of the actuall merge commit (as shown by git log ).

There is a caveat in git help revert :

   -m parent-number, --mainline parent-number
       Usually you cannot revert a merge because you do not know which side of the merge should be considered the
       mainline. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse
       the change relative to the specified parent.

       Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a
       result, later merges will only bring in tree changes introduced by commits that are not ancestors of the
       previously reverted merge. This may or may not be what you want.

So:

  • You need to find out which side of the merge you want to pick. git log , look for the line Merge: aaaaa bbbbb , and pick -m 1 or -m 2 accordingly.
  • You may want to provide the -n option to avoid the automatic commit, just to avoid a bit of hassle in case it goes wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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