How to remove a feature from master-dev after has been intermingled with other feature commits?

49 views Asked by At

Let's say we have a git repo with a master-dev branch. When developers complete their features, each feature branch in merged into the master-dev. One day, A large feature is merged into master-dev with several significant issues that are not discovered until a release branch is created. To move forward, we need to remove this feature from the master-dev and recreate the release. The issues in the feature are to be addressed after the release. What is the strategy for removing this feature?

Edit

It this scenario, after the feature branch was merged and a few problems found, several updates were applied to the feature, which were then merged back into master before the decision was made to remove the feature from the release. Those additional merges happened after other features were merged into the master-dev.

The branch history is too complicated for a simple revert command.

EDIT

If the community does not see this as a good question, I see no point in posting details about the solution that we found and used.

3

There are 3 answers

9
David Lounsbrough On

If I'm understanding correctly, you would want to simply revert that commit from the branch and then create a new release.

On the command line, this would look like:

  1. git checkout master-dev

  2. git log - make note of the most recent commit sha

  3. git revert <sha>

  4. git push

At that point you can move forward with releasing and then you can bring that commit back into your main branch at a later time.

0
Jacob Sussan On

If you want to revert a whole branch, first you would find the merge commit.

git log --oneline --graph --decorate

Then run

git checkout master-dev
git revert -m <parent-number> <merge-commit-hash>
git push origin master-dev
2
Hoyt Jolly On
  • Abandon the current master-dev branch.
  • Create a new branch from a commit with verified / tested code.
    • The last release is a good candidate.
  • Make the new branch the new master-dev.
  • Review the feature branches that need to be merged.
    • Thoroughly test each feature.
    • Remove any (old) master merge commits from each feature.
      • There should be no commits within the features that appear in the old master-dev, that don't also appear in the new master-dev.
  • Merge the working features into the new master-dev.