git: finding which merge brough commit into the current branch -


i have number of branches, periodically merged, i.e. can have a, merged b, b c, d , d c, etc. suppose have commit x, know introduces in a, , merged c somehow (i can see when git log c). there way find out merge (which merge commit) brought commit x branch c?

usually following:

git log --oneline --ancestry-path --merges <commit-of-interest>..c 

the --ancestry-path argument key here: causes git show commits both descendant of <commit-of-interest> , ancestor of c. --merges option filters resulting list further show merge commits.

each of printed merges falls 1 of following categories:

  • the merge brought <commit-of-interest> branch
  • the merge brought different branch branch has <commit-of-interest>
  • both parent branches had <commit-of-interest>

the first category 1 you're interested in. can tell category merge in looking @ commit subject line. start @ bottom of list; oldest merges in first category.

it's technically possible write script filter out merges in second , third categories (just test see if <commit-of-interest> reachable merge's first parent), i've never found necessary.

if need more in-depth study of commit history recommend looking @ history graph:

git log --oneline --graph --color --decorate \ --ancestry-path <commit-of-interest>..c 

you may want toss in --boundary too, although adds noise. use gitk, unfortunately graph draws doesn't show parentage in correct order (gitk might draw edge between merge , second parent on left; git log --graph draws second parent edge on right).


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -