I have a master and a develop branch. Feature and hotfix branches are merged into develop, and from time-to-time develop is merged into master. Now i have a request to exclude a specific hotfix from the master branch. Is this possible somehow? It was a relatively old hotfix branch, so since then i have more than 30 merges into develop. Or i should just create a new branch, reverting the changes manually and merge it to master?
Asked
Active
Viewed 632 times
0
-
If you can live with the revert-scenario then definitely do that. Getting rid of the original commit as though it never happened is certainly doable but it will be a lot more work compared to simply reverting the changes introduced by the hotfix. Personally I would try to check out the hotfix branch (or the last commit that was on it if you've deleted the branch), revert it, then merge that new commit into both develop and master. – Lasse V. Karlsen Aug 28 '17 at 08:34
-
This is an odd request. If you want to revert it forever (not a one time thing for one user) than definitely just make a new commit reverting the changes manually. If contained in a few files than a simple diff/checkout of those files from before the hotfix may be enough. I think though you should elaborate why you would even accept this request. Perhaps the answer is elsewhere. – kabanus Aug 28 '17 at 08:38
1 Answers
1
You just need to revert the commit which the old hotfix
was merged into develop
branch.
Assume as below graph, you the old hotfix you want to excluded on master
branch is the commits from commit F
to commit G
.
A---B------------------I---… master
\ /
C---D---E--…--H---… develop
\ / \
F--…--G J--… hotfix/feature
You use use below way to exclude the old hotfix
on your master
branch:
First, find the merge commit that the old hotfix
merged into develop
branch. As the merge commit H
on develop branch.
Then revert the changes on your master
branch:
git checkout master
git revert -m 1 <commit id for H>
Note: if there is conflicts when revert the merged changes, you can modify and save the conflict files, and you git add .
and git revert --continue
to finish the revert.

Marina Liu
- 36,876
- 5
- 61
- 74