How to Compare Branch in GIT

COMPARE BRANCH

  • Compare two branches (local) and show how much commits each branch is ahead of the other
git rev-list --left-right --count <branch1>...<branch2>

DIFF STATUS

  • Get differences status between local (checked-out) branch and its respective remote (tracked) branch
git checkout <local-branch>
git status -sb
Example Output: ## <local-branch>...<remote-branch> [ahead 2, behind 1] 

DIFF AHEAD revisions of local branch

  • To see differences of ahead-revisions (in local-branch)
git diff <local-branch>...<remote-branch>^
E.g.
git diff master...origin/master^ 

DIFF BEHIND revisions of REMOTE branch

  • To see differences of ahead-revisions (in local-branch)
git diff <remote-branch>...<local-branch>^^
E.g.
git diff origin/master...master^^

* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.

Leave a Reply

Your email address will not be published. Required fields are marked *