I just finished a fairly large branch that I've been working on for over 2 months. I just rebased master into it and had to resolve a handful of conflicts. Now that I have rebased my feature branch, how can I go through file by file to see the highlighted differences of that compare on the featured branch compared to the master branch to make sure the rebase was done correctly?
3 Answers
Like this:
git diff master
You could provide a single file at a time:
git diff master -- some-file-path

- 26,375
- 3
- 36
- 60
git diff branch1..branch2
Using this command, Git will compare the tip of both branches (also called the HEAD) and display a “diff” recap that you can use to see modifications. In short, it will show you all the commits that “branch2” has that are not in “branch1”.
git diff branch1...branch2
Using “git diff” with three dots compares the top of the right branch (the HEAD) with the common ancestor of the two branches.

- 221
- 1
- 5
Most answers here suggest using git diff
, but the con of that approach is that it shows the diff right in the console, which is not always convenient.
Here are some alternatives which will open GUI instead.
Using Gitk
Usually, while git (especially on Windows, with git-scm) you get a GUI tool called GitK which can be used to show the changes. So, just type:
gitk --all
And GUI will be opened where you can see the commits and the changes done by each commit.
Using DiffTool
Use git difftool
instead, and show the diff in the preferred diff tool.
Just type difftool
instead of diff
in the console like this:
To see the changes between 2 branches:
# For all the files
git difftool branch1..branch2
# For a single file
git difftool branch1..branch2 "filepath"
To see the changes on the last commit
# For all the files
git difftool HEAD~1
# For a single file
git difftool HEAD~1 "filepath"
To see the changes since the commit with ID (all/single file):
# For all the files
git difftool commitId
# For a single file
git difftool commitId "filepath"
To see the changes between 2 commits:
# For all the files
git difftool commitId1..commitId2
# For a single file
git difftool commitId1..commitId2 "filepath"
Notes
- The
difftool
will open your default diff tool which is usually set to VimDiff.
But if you'd like to change it to something else, simply change id with this.
In my case, I've used Visual Studio as a diff tool, and this is how it works: - If you'd still like to see the changes right in the console, just use the commands above with
git diff
instead ofgit difftool
by leaving the parameters the same.

- 10,860
- 6
- 57
- 75
-
` Here are some alternatives which will open UI instead.` - you mean GUI. Command line interface is UI as well. – Arkadiusz Drabczyk Feb 01 '20 at 12:58
-
Yep! I meant that. Thanks for noticing! Fixed. – Just Shadow Feb 01 '20 at 14:39