0

I've come upon some instances that are difficult to track what the heck happened. We have a 'development' and 'master' branch. New changes get taken from 'master' then merged into 'development' then once good we merge the new branch into 'master'.

Sometime in the last couple weeks a huge set of changes was reversed on development. I don't know how that happened or how that's possible. Anyways, it would be nice if I could go into the history of a file and see the merge that reversed it, but it's showing as if the last merge was from a year ago.

The only real way I can think of this is to literally go through the commit hashes and reset head to them and see where I'm at. But that seems impractical. Any easier way to do this?

OR is there a way to look at a merge in the past and see which files were effected by it? Like when you merge a branch you always see the output in your console of which files were changed at which lines.. but in the git file history much of that may not show up.

Also does anyone know why this may happen? I've seen it happen a few times. Sometimes I catch it when I merge. Like I merge a new branch into another and I know I only changed one file in the last commit but it changes a ton of other files. Master branch is about a year behind on a large set of updates so I'm thinking for some reason when a new branch from master was created and merged into dev it switched all the other files too. Weird though since we always do that and it 99% of the time only changes the changed files. I don't get it!

wejrowski
  • 439
  • 5
  • 20

1 Answers1

1

There's a couple git tricks that might help you here.

first off, git show <commit hash> will show you all the changes made in a particular commit. git blame <filename> will show you a file, and tell you which commits changed that file, line-by-line.

[added in response to comment]:

git diff <ref1>...<ref2> will show the sum total differences between two commits. This is a little odd in the case of a merge, what you'd probably want to do is something along the lines of git diff HEAD <merge_parent_1> and git diff HEAD <merge_parent_2>, to see what each branch brought to the table.

Finally, if you have a known good old commit (say you found it with git show), you can use git bisect to step through a binary search to find the commit where things went screwy.

YenTheFirst
  • 2,172
  • 13
  • 11
  • hmm. So I'm trying that and it doesn't seem to show all of the changes. I'm going over a complex commit from the other day (merging a big branch, and changing/fixing multiple files in the process). Git show only shows some of the conflicts. It was actually 20-30 files changed/altered. I'm in tower too looking at that commit & it's showing 14 files—maybe the files that were only actually touched in that commit/merge??—why and HOW do I see the ones that were modified with that? I want to get that same output I get when I do the initial git merge branchname. Where it shows every single file. – wejrowski Apr 13 '12 at 17:15
  • according to http://stackoverflow.com/questions/5072693/how-to-git-show-a-merge-commit-with-combined-diff-output-even-when-every-chang, you can't really do that straight off of a merge. You can do `git diff` between two commit numbers, though. – YenTheFirst Apr 13 '12 at 22:55