A lot of developers avoid merging like the plague. Most common source control tools only support two-way merges out of the box. Many mistakes occur through bad merges (goto fail, maybe?). Correlation? Causation? We can fix that! Let's configure git to use a free, commercial-grade three-way merge tool and see how fun and fearless merging can be.
4. We Can Do Better!
Copyright 2015, Stephen Vance Three-ways Are Better 4
5. But How?
1. Download and Install P4Merge
2. Add it to your PATH
export PATH=${PATH}:/Applications/p4merge.app/Contents/MacOS
3. Configure git to know about it
git config --global merge.tool p4merge
git difftool --tool-help
4. Use it!
git difftool some.txt
Copyright 2015, Stephen Vance Three-ways Are Better 5
6. Meanwhile, Back In The Console
• You can turn that off
– git difftool --no-prompt some.txt
– git config mergetool.prompt off
Copyright 2015, Stephen Vance Three-ways Are Better 6
7. I Thought You Said “Merging”
git config --global merge.tool p4merge
Copyright 2015, Stephen Vance Three-ways Are Better 7
8. Set Up Your Merge
git checkout master
git merge other
git mergetool
Copyright 2015, Stephen Vance Three-ways Are Better 8