cherry-pickをした際、通常commitされてしまう。
commitせずに、差分のみを反映させたいときのメモとして残しておく。
また、cherry-pickした際にコンフリクトした際やcherry-pickしたcommitを分割したいときなどにも有効である。
# 1. cherry-pickをする。
git cherry-pick <commit hash>
# -> コンフリクトが発生
# 2. cherry-pickを中止する。
git cherry-pick --abort
# 3. コミットせずに差分だけ持ってくる。
git cherry-pick <commit hash> --no-commit
# 4. 通常通りcommitする。
git add -p
git commit -m "commit message"
...
git cherry-pick <commit hash> --no-commit でコミットせずに差分だけ持ってくることができる。
※--no-commit を -n に省略しても指定可能
参考:
https://git-scm.com/docs/git-cherry-pick/2.50.0#Documentation/git-cherry-pick.txt--n