git diff compare feature branch with unstaged current changes

less than 1 minute read

Compare current unstaged changes vs. another branch feature1, with the ability to line-by-line implement changes using meld:

git difftool feature1 -- .

Why not simply checkout another new branch feature2 and then do

git difftool feature1..feature2

You would rather do the first method because this second command only compares committed changes, causing you to make an excessively large number of commits when you’re not sure which change caused the break in compile or run.

Install meld for git

meld is an extremely useful GUI for two-way and three-way file comparisons as well as directory comparisons. You really are missing out if you aren’t using something like this.

To use meld for git difftool and git mergetool

  1. one-time configure:
    git config --global diff.tool meld
    git config --global merge.tool meld 
    
  2. Install Meld
    • Linux: apt install meld
    • Mac: brew install meld
    • Windows:
      1. Download/install Meld for Windows.
      2. Download/install Git for Windows.
      3. in the Git Bash shell
        git config --global diff.tool meld
        git config --global merge.tool meld
        git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\meld.exe"
        

Tags:

Categories:

Updated:

Leave a Comment