chore(shell): add git find merge commit
This will output the git sha of the merge commit that a given commit is part of. This can be used to get back to the pull request a commit was part of. Or it can be used to help revert a hole changeset rather than only one commit.
This commit is contained in:
parent
331e2ceaf9
commit
77575fc2a7
1 changed files with 7 additions and 0 deletions
7
site-modules/core/files/bin/git-find-merge
Executable file
7
site-modules/core/files/bin/git-find-merge
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
# See: https://stackoverflow.com/questions/8475448/find-merge-commit-which-includes-a-specific-commit
|
||||
|
||||
commit=$1
|
||||
branch=${2:-HEAD}
|
||||
candidates=$(git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n)
|
||||
echo "$candidates" | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2
|
||||
Loading…
Reference in a new issue