0

I'm trying to solve a git mystery. A commit made on a feature branch that had been merged to qa unexpectedly showed up on master. The developer who last pushed to master says they did not merge qa or the feature branch into master before pushing. I also do not see a merge commit that says "Merge branch 'qa' into 'master'.

Is there a git command that will show the merge history for a single commit?

Marek R
  • 32,568
  • 6
  • 55
  • 140
Seth Reno
  • 5,350
  • 4
  • 41
  • 44

2 Answers2

0

there are multiple ways for determining what happened. The first is:

git log

You are probably familiar with this one as you mentioned you haven't seen any merge to master messages. the second is:

git blame

This will allow you to go over each line in the file and determine what commit and by what user it had been inserted from. Aside from those commands, if your repo is on GitLab or a similar repo system, they have tools to look that information up on their host website. Let me know if you have any questions.

Oren_C
  • 565
  • 7
  • 22
0

The git log contains the information you're looking for, but it can be hard to find. One way to pare it down is to track a single change from that commit.

First, locate the current position of one of the lines in that commit, note the line number of a change from the commit you're tracking:

git blame <file>

Then track everything that has happened to that change:

git log --graph --oneline -l <line>:<file>

You can further pair this down by only showing changes since that commit:

git log --graph --oneline -l <line>:<file> <commit>~..master

This should make it much easier to track what happened to get the commit into master.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
LightBender
  • 4,046
  • 1
  • 15
  • 31