LoginSignup
6
6

More than 5 years have passed since last update.

あるbranchのあるファイルに関するcommitだけを全部cherry-pickしたい

Last updated at Posted at 2016-03-01

今日

hogebranch の a.txt に関する commit だけを全部 cherry-pick したくなるということが起きた

結論

こうやったけど、

$ a=(`git log --pretty=format:%h hogebranch -- a.txt`)
$ for ((i=${#a[@]}-1; i>=0; i--)); do git cherry-pick ${a[$i]}; done

あとでリバースっていうオプションがあることに気づいたので、これで同じことができたし、

$ for a in `git log --reverse --pretty=format:%h hogebranch -- a.txt`; do git cherry-pick $a; done

さらにいま cherry-pick が複数のコミットハッシュを引数に取れることがわかったので、これがオススメ

$ git cherry-pick `git log --reverse --pretty=format:%h hogebranch -- a.txt`

ちなみに、上記の a.txt の部分は何らかのディレクトリ名にも置き換え可能で、
ある fugadirectory 以下の変更を全部 cherry-pick したくなったときにも便利

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