InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Git tutorials

  • Github for beginners
  • Undo last commit
  • List git branches
  • Git checkout remote branch
  • Diff two branches
  • Show log of one user's commits
  • View diff for a given commit id
  • Setup password less git push for github
  • Git - Check if a hash is valid
  • Git - display specific length commit hash
  • Git - rename local branch
  • Git create branch
  • Git delete branch
  • Git detached head
  • Git display info of last commit (HEAD) in one line
  • Git display local HEAD location
  • Git log with file names
  • Git show details of a commit hash
 
  • Home
  • > Tutorials
  • > Git

git – how to diff two branches

By admin on Nov 19, 2015

It is sometimes useful to be able to diff two branches in git. This can be useful to understand the changes in a git repository better. For the purpose of this article we we clone Sunshine-Version-2 repositoty at https://github.com/udacity/Sunshine-Version-2.

$ git clone https://github.com/udacity/Sunshine-Version-2
$ git checkout 1.01_hello_world
$ git checkout 1.03_update_fragment_layout

git – diff local branches

To diff local branches in git

$ git diff 1.01_hello_world..1.03_update_fragment_layout

git – diff local branches name only

To diff and print only names two local branches in git

$ git diff --name-only 1.01_hello_world..1.03_update_fragment_layout
app/src/main/res/layout/fragment_main.xml
app/src/main/res/layout/list_item_forecast.xml

git – diff local branches – stat

To diff and print only stat two local branches in git

$ git diff --stat 1.01_hello_world..1.03_update_fragment_layout
app/src/main/res/layout/fragment_main.xml      | 18 ++++++++++++------
app/src/main/res/layout/list_item_forecast.xml |  8 ++++++++
2 files changed, 20 insertions(+), 6 deletions(-)

git – diff local branches – with color

To diff with color two local branches in git

$ git diff --color 1.01_hello_world..1.03_update_fragment_layout

Here is how it looks:
git-color-diff

git – diff remote branches

To diff local branches in git

$ git diff origin/1.01_hello_world..origin/1.03_update_fragment_layout

Suggested posts:

  1. How to find a user’s first tweet
  2. WordPress – write custom php log to separate file
  3. Vim – highlight and move to matching bracket
  4. Svn – short diff without context
  5. Bash check if file begins with a string
  6. Linux file timestamps
  7. Php look ahead and look behind regex examples
  8. Git create branch
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Git, Linux, Mac, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress