Merging git branch A into branch B once again after the first merge has been reverted -
my situation presented below.
o---o---o issue-2 / \ o---o---o---o---m---r---o develop \ / o---o---f issue-1
there work on issue-1. after review, merged develop (commit m). unfortunately, discovered there serious errors present. sake of other issues merge commit reverted (commit r). later, other issues (like issue-2) merged develop. code on original branch fixed (commit f).
the problem - how merge issue-1 develop now? simple merge keep effect of revert commit r , apply changes not in develop branch (commit f), not of them.
there few options:
- revert revert
- pros: approach recommended git documentation, , it's easy do
- cons: uglies history, makes little more difficult people understand how code evolved on time (e.g.,
git blame
show revert of revert instead of individual commits onissue-1
branch)
- rebase reverted branch , merge
- pros:
git blame
, other history digging tools make easier understand code history - cons: looking @ history can bit confusing (why there 2 seemingly identical sets of commits in history? did botch rebase?)
- pros:
- edit history: redo develop branch remove both commit
m
, commitr
- pros: cleanest end result
- cons:
- dangerous if repository shared, unless users git , have communicated plan everyone
- difficult because git doesn't have easy history editing tool:
- rebase doesn't make easy edit (or edit out) merges, ,
--preserve-merges
option doesn't work interactive rebasing you'll end flatteningissue-2
commitsdevelop
filter-branch
difficult use
- rebase doesn't make easy edit (or edit out) merges, ,
in general approach recommend revert revert. suggest following these detailed steps:
- check out original bad branch:
git checkout issue-1
- merge in latest commits parent branch:
git merge --no-ff develop
- revert revert (where
r
sha1 id of revert commit):git revert r
- fix flaws in branch. (you've done in commit
f
; others' sake i'll assume need make additional fix.) - test test test
- switch parent branch:
git checkout develop
- merge in repaired branch:
git merge --no-ff issue-1
the resulting graph should this:
o---o---o issue-2 / \ o---o---o---o---m---r---o-------------o develop \ / \ / o---o---f-------o---rr---f2 issue-1
it's not pretty, people should able figure out what's going on.
Comments
Post a Comment