Skip to content

Instantly share code, notes, and snippets.

@banyudu
Created November 12, 2020 06:21
Show Gist options
  • Select an option

  • Save banyudu/ea188ba4e152e5fc0e9749aaa6876258 to your computer and use it in GitHub Desktop.

Select an option

Save banyudu/ea188ba4e152e5fc0e9749aaa6876258 to your computer and use it in GitHub Desktop.
git find-merge command
# copied from https://stackoverflow.com/a/30998048/2380603
[alias]
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment