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:

  1. 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 on issue-1 branch)
  2. 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?)
  3. edit history: redo develop branch remove both commit m , commit r
    • 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:

in general approach recommend revert revert. suggest following these detailed steps:

  1. check out original bad branch:
    git checkout issue-1
  2. merge in latest commits parent branch:
    git merge --no-ff develop
  3. revert revert (where r sha1 id of revert commit):
    git revert r
  4. fix flaws in branch. (you've done in commit f; others' sake i'll assume need make additional fix.)
  5. test test test
  6. switch parent branch:
    git checkout develop
  7. 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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -