0
0

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 1 year has passed since last update.

git cherry-pickでconflictした時、commitせずに差分のみを反映させる

0
Last updated at Posted at 2025-11-10

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

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?