Visual Diff and Merge Tools¶
โ Back to Git
๐๏ธ Visual Diff and Merge Tools¶
You can configure external tools like P4Merge to visualize diffs and resolve conflicts more easily than in the CLI.
1. Install Tool¶
Install your preferred tool (e.g., P4Merge).
2. Configure Git¶
Run the following commands to set P4Merge as your default merge and diff tool (adjust paths for your OS):
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global diff.tool p4merge
git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global difftool.prompt false
git config --global mergetool.prompt false
3. Usage Commands¶
View Diff (Changes not stamped):
git difftool
Diff Working Directory vs Last Commit:
git difftool HEAD
Diff Staging Area vs Last Commit:
git diff --staged HEAD
Diff Between Two Commits:
git difftool <commit-hash-1> <commit-hash-2>
Diff Local vs Remote Branch:
git diff master origin/master
๐ง Quick Quiz โ Diff Tools¶
#
Which command allows you to view changes using an external visual tool?
๐ Want More Practice?¶
๐ Start Git Advanced Quiz (20 Questions)
๐ฌ DevopsPilot Weekly โ Learn DevOps, Cloud & Gen AI the simple way.
๐ Subscribe here