Git is a workflow problem. Delete merged branch from another branch

I have a feature branch that has been merged several times with the development branch over the past few weeks. Before merging it into a master branch, we want to remove the code of the function branch that has been merged into the development branch over the past few weeks. Is there a single way to do this?

Merges were created with -no-ff, so commits in the new branch must have their own objects.

_______ master ______________________________ \ / \ / \__hofix-1_____C/ \ _ development _______________________\____________ \ / / / \ / / / \_feature-test__A/_________B/________D/ 

So, I want to remove the combined commits A, B, and D from development, while preserving fix-1, merging C, and continue to work on the function branch.

+4
source share
2 answers

If I understand your situation correctly, I don’t think you need something as heavy as rebase, revert and the like. You can simply do this:

  • look through the development log to find the commit hash just before merging A and create a new branch named "new-dev":

    git checkout -b new-dev somecommithash

  • now merge in C from the hotfix-1 branch:

    git merge C

... and you're done. the new-dev branch now has development content combined with C, minus AB and D.

If now you want the branch point of the developer to be in the same place as the new-dev branch, it is as simple as:

 git branch -f developer new-dev 

But for security, you might want to tag the branch of the branches of the old developer with a tag or branch before forcing it to a new location.

+1
source

The question is somewhat fuzzy. Do you have a dev branch and want to unload some incoming merges, leaving the rest? If so, you can use rebase -i -p with some low point, removing the merge commands from the todo list. Please note that you must double-check all the commits that you pulled things on, since the next work can be built on it.

Another approach is to use git revert from above for unwanted changes. It gets the final result, but it probably leaves you with a poor history of quality.

+4
source

Source: https://habr.com/ru/post/1488701/


All Articles