Book Image

Git Version Control Cookbook

By : Aske Olsson, Rasmus Voss
Book Image

Git Version Control Cookbook

By: Aske Olsson, Rasmus Voss

Overview of this book

Table of Contents (19 chapters)
Git Version Control Cookbook
About the Authors
About the Reviewers

The difference between branches

Checking the difference between branches can show valuable information before merging.

A regular Git diff between two branches will show you all the information, but it can be rather exhausting to sit and look at; maybe you are only interested in one file. Thus, you don't need the long unified diff.

Getting ready

To start with, we decide on two branches, tags, or commits we want to see the diff between. Then, to list files that have changed between these branches, you can use the --name-only flag.

How to do it…

Perform the following steps to see the difference between the branches:

  1. Diff the origin/stable-3.1 with origin/stable-3.2 branch:

    $ git diff --name-only origin/stable-3.1 origin/stable-3.2 org.eclipse.jgit/src/org/eclipse/jgit/transport/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetch
    More output..
  2. We are building the command in this pattern, that is, git diff [options] <commit> <commit> <path>. Then, we can diff what we care...