no-image

[git cherry-pick]他ブランチ変更を自分のブランチに取り込む

チーム開発をしていると、他の人のブランチでが変更された内容を自分のブランチに取り込みたい場合がある

その対処法を紹介。

解決方法のひとつに git cherry-pick を使うというものがある。

Apply the changes introduced by some existing commits

https://git-scm.com/docs/git-cherry-pick

とあるように、コミットを元に変更を適用してくれる。

使い方は以下の通り

git cherry-pick 4b0774ffe といったように、commit hash を後ろに加える。

$ git cherry-pick 4b0774ffe
[feature/hoge3d0e697] change date
 Author: sumito.tsukada <sumito.tsukada@hoge.com>
 Date: Wed Jan 12 11:07:04 2022 +0900
 1 file changed, 2 insertions(+), 2 deletions(-)

覚えておくとなにかと便利。