cherry-pickをマージコミット、各々のコミットでどのような差分が出るか?
概要
既にマージ済みのはずなのに差分として表示された。
推測によると、マージコミットをチェリーピックしているので発生するらしい。
多分、差分は見えない方が良いので、どのようにすべきかを検証する。
前提
ブランチ feature/xxxxxx
| ブランチ | feature/xxxxxx |
|---|---|
| masterへのマージコミット | 61316a0f5f41dca335beea470cb8d360ceb36c3c |
| ブランチへのコミット | 1dcded16f672fccc34aa62b5969faae9b84c8622(古い)、d16c782849f4943b5333a44135332b3f2507bc75、d00bff9c06e341e53281b9a4b49f604be0000ee4(新しい) |
git log --graph --decorate --oneline でマージ具合を見れるはず。
作業前
* 0fe91041 (HEAD -> feature/tmp-staging, origin/staging, staging) Merge branch 'xxx-production-1' into 'staging' |\ | * 2e7c5b0d (origin/xxx-production-1) production xxx |/ * 11d80946 Merge branch 'feature/xxx_staging' into 'staging' |\ | * e2ba12c8 (origin/feature/xxx_staging) xxx |/ * 8010007f Merge branch 'feature/xxx_staging' into 'staging' |\ | * 1cdba73c (origin/feature/xxx_staging) xxx feature/tmp-staging
で作業する。
検証
私の方法だと、MRのCommitsタブを開いて、下から順にコミットIDを列挙する方法を考えた。
git cherry-pick a b c…
これと、Merge branchのコミットをチェリーピックするのはどのような差分が起きるのか?
マージコミットをチェリーピックする場合
$ git cherry-pick -m 1 61316a0f5f41dca335beea470cb8d360ceb36c3c [feature/tmp-staging d61144b2] Merge branch 'feature/xxx' into 'master' Author: xxx <xxx@xxx> Date: Mon Oct 26 17:54:49 2020 +0900 13 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 path/to/file ... * d61144b2 (HEAD -> feature/tmp-staging) Merge branch 'feature/xxx' into 'master' * 0fe91041 (HEAD -> feature/tmp-staging, origin/staging, staging) Merge branch 'xxx-production-1' into 'staging' |\ | * 2e7c5b0d (origin/xxx-production-1) production xxx |/ * 11d80946 Merge branch 'feature/xxx_staging' into 'staging' |\ | * e2ba12c8 (origin/feature/xxx_staging) xxx |/ * 8010007f Merge branch 'feature/xxx_staging' into 'staging' |\ | * 1cdba73c (origin/feature/xxx_staging) xxx コミットを範囲指定で指定する場合
$ git cherry-pick 1dcded16f672fccc34aa62b5969faae9b84c8622^..d00bff9c06e341e53281b9a4b49f604be0000ee4 [feature/tmp-staging c4be1be0] xxx Author: xxx <xxx@xxx> Date: Mon Oct 26 17:01:45 2020 +0900 12 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 path/to/file ... [feature/tmp-staging af9edeec] xxx Author: xxx <xxx@xxx> Date: Mon Oct 26 17:05:05 2020 +0900 1 file changed, 3 insertions(+) [feature/tmp-staging c99bab38] xxx Author: xxx <xxx@xxx> Date: Mon Oct 26 17:49:01 2020 +0900 1 file changed, 1 insertion(+), 1 deletion(-) * * c99bab38 (HEAD -> feature/tmp-staging) xxx * af9edeec xxx * c4be1be0 xxx * 0fe91041 (HEAD -> feature/tmp-staging, origin/staging, staging) Merge branch 'xxx-production-1' into 'staging' |\ | * 2e7c5b0d (origin/xxx-production-1) production xxx |/ * 11d80946 Merge branch 'feature/xxx_staging' into 'staging' |\ | * e2ba12c8 (origin/feature/xxx_staging) xxx |/ * 8010007f Merge branch 'feature/xxx_staging' into 'staging' |\ | * 1cdba73c (origin/feature/xxx_staging) xxx This post is licensed under CC BY 4.0 by the author.