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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章