ゲーム業界エンジニアの独り言

クライアント、サーバ、インフラなどなど興味あることなんでも紹介

他のブランチへ特定のコミットをマージする

cherry-pickを使用すると、他のブランチをマージするのではなく、 特定のコミットだけをマージする事が出来る。

$ git cherry-pick
usage: git cherry-pick [options] <commit-ish>...
   or: git cherry-pick <subcommand>

    --quit                end revert or cherry-pick sequence
    --continue            resume revert or cherry-pick sequence
    --abort               cancel revert or cherry-pick sequence
    -n, --no-commit       don't automatically commit
    -e, --edit            edit the commit message
    -s, --signoff         add Signed-off-by:
    -m, --mainline <n>    parent number
    --rerere-autoupdate   update the index with reused conflict resolution if possible
    --strategy <strategy>
                          merge strategy
    -X, --strategy-option <option>
                          option for merge strategy
    -x                    append commit name
    --ff                  allow fast-forward
    --allow-empty         preserve initially empty commits
    --allow-empty-message
                          allow commits with empty messages
    --keep-redundant-commits
                          keep redundant, empty commits

例えば、masterブランチに特定のコミットをマージしたい場合はこんな感じ。

$ git checkout master
$ git cherry-pick 965e5f980e4d7ee848c2163fc75def15d88d3524 

独習Git

独習Git