1

I was trying to do this which didn't show anything different How to get the changes on a branch in git

I did a branch from master and since then changes have been made on master and my branch (called performance). All I want is

  1. The list of files changed/touched since branching "performance" branch (all files were committed)
  2. Show the complete difference of all those files changed/touched.

When doing git diff origin/master, it lists all changes on both branches :(.

What is the command since git diff HEAD..performance shows nothing(and ... also shows nothing)? Also, using log in the same way with .. and with ... also shows nothing.

If I do git log, I do see the commit I made on the performance branch with my comment about performance as well.

thanks, Dean

Community
  • 1
  • 1
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
  • Can you try this and see if its what you are after? git diff hash1 hash2 – David K Jul 05 '13 at 17:18
  • I don't know which hashes to use as I only know the last commit was on this branch but I am not sure about the other commits and where it finally forked from master branch. – Dean Hiller Jul 05 '13 at 17:28

1 Answers1

2

First, find the branch point. You can do this with the merge-base command:

$ git merge-base performance master
cafebabe01234567...

Note: If you don't remember the merge-base command, you can always use gitx/gitk/gitg/etc. to find the branch point visually.

Then, you can do a diff from the branch point to the tip of the performance branch:

$ git diff cafebabe01234567... performance

Or, in a single line,

$ git diff $(git merge-base performance master) performance

Remember that git diff takes options, if you want to change how it displays the differences. See the man page.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
  • Cheers, I'll know the next time! – David K Jul 05 '13 at 17:31
  • well, it is definitely giving the wrong fork revision as the date on that is way way back in May and I just created this branch yesterday sometime. Why would it give me something from May on what is a very new branch? – Dean Hiller Jul 05 '13 at 17:44
  • oh, and I took the hash from git merge-base performance master and then did a git log and searched for the hash and it is way back in May which is definitely wrong. – Dean Hiller Jul 05 '13 at 17:44
  • oh crap. this really screwed things up. I ran that command on performance branch which gave me that hash but then when I did git checkout master to get back on master, it says I am behind by 238 commits...it wasn't doing this a few hours ago when I was on master branch and switching back and forth....how do I fix this? I thought the command you gave me was not modifying anything but it seems to have done some stuff that I didn't want to do to my repository. My performance branch is local as well so I can't just blow away and clone :( :( – Dean Hiller Jul 05 '13 at 17:47
  • ah crap, did a git pull, go back to performance branch and run same merge-base command and now it gives a different hash...this just screws things up worse – Dean Hiller Jul 05 '13 at 17:50
  • I am not sure what happened but now it seems to have stabilized and is actually giving me a commit that was probably the fork....this is soooo weird. – Dean Hiller Jul 05 '13 at 17:54
  • Neither `git merge-base` nor `git diff` will modify your repository, and neither command requires that you check out a branch. They will produce the same results no matter which branch you are on when you run the commands. – Dietrich Epp Jul 05 '13 at 18:01
  • However, you will get a different result if you start modifying your repository with `git pull`, which is equivalent to running `git fetch` and `git merge` (both of which modify the repository). – Dietrich Epp Jul 05 '13 at 18:02