5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitで特定のコミットを含むマージコミットを検索する

Last updated at Posted at 2018-07-31

備忘録です、先人達の知恵に感謝!!
git - Find merge commit which include a specific commit - Stack Overflow

gitconfigにaliasを登録

gitconfigはC:/Users/{username}/.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

表示が文字化けする場合

環境変数に言語設定を追加する。

変数名:LANG
変数値:en_US.UTF-8
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?