Something happened to our dev branch such that a lot of code from the release branch got merged into it. I'm trying to track down where these changes occurred but I get some very puzzling results. When I run git diff HEAD@{2}
it shows a list of changes including many files that haven't been touched in months, implying that HEAD@{2}
is the commit that brought in the bad code as I see it. However if I run git show HEAD@{2}
it shows a rather innocuous commit that only touches two files. Further, when I run git reset --hard HEAD@{2}
it seems to fix the issues and to top off all the weirdness after I tried that reset twice and then undid it with git reset --hard origin/dev
it now appears that the commit with all the extra code is at HEAD@{1}
.
I can't seem to make head or tails of this so any suggestions/pointers/tips or tricks would be welcome but some directed questions that are puzzling me are: how can this code have gotten into the branch if there wasn't a merge commit? If someone cherry-picked a commit from a production branch to the dev branch could that be related to this? What are the differences (if any) in how git show
and git diff
resolve commits?
The current theory I have given limited git knowledge: it seems that these changes weren't part of any commit but somehow got into the tree right around HEAD@{2}
so diff
shows the changes as it walks the object tree but show
doesnt see them as they're not part of a commit. Does this make any sense or am I way off base?
Either way, thanks for any help you can give!