0

I've branch from master do few commits and then I add lots of commits to master then how can show file difference between HEAD of the branch and commit from which I branch.

What I need is same diff I have when I create pull request on github, but from command line and for a branch.

The problem is that I don't know which commit was HEAD when I've run git branch.

jcubic
  • 61,973
  • 54
  • 229
  • 402
  • possible duplicate of [Show all changed files between two Git commits](http://stackoverflow.com/questions/1552340/show-all-changed-files-between-two-git-commits) or [Comparing two branches in GIT](http://stackoverflow.com/questions/9834689/comparing-two-branches-in-git) – Kleskowy Aug 29 '14 at 14:33
  • @Kleskowy I don't what commit I need to compare to. I need to get commit from the branch, Commit that was `HEAD` when I've run `git branch`. – jcubic Aug 29 '14 at 15:15
  • Try $ [git lola](http://blog.kfish.org/2010/04/git-lola.html) then - I find it very useful: (or if you do not want to create any aliases: $ git log --graph --decorate --pretty=oneline --abbrev-commit --all) – Kleskowy Sep 02 '14 at 09:56

1 Answers1

1

I don't what commit I need to compare to. I need to get commit from the branch, Commit that was HEAD when I've run git branch.

What you need is git merge-base to find the most recent common ancestor aka "the commit that was HEAD" when you ran git branch.

But to find the diff you can use this form :

git diff [--options] <commit>...commit> [--] [<path>...]

This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both . "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of , which has the same effect as using HEAD instead.


Emil Davtyan
  • 13,808
  • 5
  • 44
  • 66