git clone https://gist.github.com/abef31ca104ecffa2d99fb904aadcf59.git git-merging
cd git-merging
Merge the change-value
branch into master
, to bring in the change of value:
git merge origin/change-value
will fail with "Automatic merge failed; fix conflicts and then commit the result."- Edit
app.pl
and keep the top block after the conflict marker, make the change from7
to42
and delete the unused block and all conflict markers. git add app.pl
git commit
Tip: if it goes wrong when editing, run git merge --abort
and start again.
The git log will now contain the original master commits, the change from 7 to 42 and then a merge commit that brings both together (with your alteration).
Check out the change-value
branch and rebase (update it) on master
.
git checkout change-value
git rebase master
- Edit
app.pl
and keep the top block after the conflict marker, make the change from7
to42
and delete the unused block and all conflict markers. git add app.pl
git rebase --continue
Tip: if it goes wrong when editing, run git rebase --abort
and start again.
The git log will now contain all of the master commits, then a single change from 7 to 42 in the refactored method from master.
If you now repeated the merge of change-value
into master
, it would merge
cleanly.