First, clone a remote Git repository and cd into it:
$ git clone git://example.com/myproject
$ cd myproject
Next, look at the local branches in your repository:
$ git branch
* master
But there are other branches hiding in your repository! You can see these using the -a
flag:
$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental
If you just want to take a quick peek at an upstream branch, you can check it out directly:
$ git checkout origin/experimental
But if you want to work on that branch, you'll need to create a local tracking branch which is done automatically by:
$ git checkout experimental
and you will see
Branch experimental set up to track remote branch experimental from origin.
Switched to a new branch 'experimental'
Here, "new branch" simply means that the branch is taken from the index and created locally for you. As the previous line tells you, the branch is being set up to track the remote branch, which usually means the origin/branch_name branch.
Now, if you look at your local branches, this is what you'll see:
$ git branch
* experimental
master
You can actually track more than one remote repository using git remote
.
$ git remote add win32 git://example.com/users/joe/myproject-win32-port
$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental
remotes/win32/master
remotes/win32/new-widgets
At this point, things are getting pretty crazy, so run gitk
to see what's going on:
$ gitk --all &
To compare the current branch against main
branch:
$ git diff --name-status main
To compare any two branches:
$ git diff --name-status firstbranch..yourBranchName
There is more options to git diff
in the official documentation (and specifically --name-status
option).
Best Answer
Short & sweet:
This configures Git to use
meld
as the diff tool. (You don't need to specify the command line arguments, support formeld
is built into Git.)Then, if you want a graphical diff instead of a textual one, you simply invoke
git difftool
instead ofgit diff
(they both take the same arguments). In your case:Update: If you don't want the one-file-at-a-time diff, but instead want to use meld's "subdirectory" view with all the changes between the two branches, note the
-d
or--dir-diff
option forgit difftool
. For example, when I'm on branch XYZ and I want to see what is different between this and branch ABC, I run this: