Git 查看指定 commit 何时 merge 进指定分支

摘抄自

Git 查看指定 commit 何时 merge 进指定分支

内容

在 git 配置文件 ~/.gitconfig 中追加以下别名:

[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'"

操作

# current branch
git find-merge <SHA-1>
# specify master
git find-merge <SHA-1> master

实际操作

  1. 找到commit
  2. 切到目标分支,
  3. 执行find-merge
  4. 执行show-merge
checkout 
git find-merge 5876dae1f
git find-merge 5876dae1f
posted @ 2023-06-28 10:58  躲在墙角的  阅读(18)  评论(0编辑  收藏  举报