チュートリアル3 コミットを書き換えよう! 4. cherry-pick

このチュートリアルでは、あらかじめ履歴が準備されているローカルリポジトリを使用します。
こちらからダウンロードしてください。

stepup-tutorial/tutorial4ディレクトリに移動します。このリポジトリの履歴は次の図で表す状態になっています。
ここでは、別のブランチで行った「commitの説明の追加」という変更だけをmasterブランチに取り込みます。

masterブランチに移動した後、cherry-pickを使って、「commitの説明を追加」したコミットを取り出してmasterに追加します。(ドキュメント内のコミット"867f46c"と、ダウンロードしてきたリポジトリ内のコミットは異なっている可能性があります。ダウンロードしてきたリポジトリ内でgit logを実行し、適切なコミットを確認して使用してください。)

$ git checkout master
Switched to branch 'master'
$ git cherry-pick 867f46c
error: could not apply 867f46c... commit
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

競合が発生しました。sample.txtを開いて競合箇所を修正してから、コミットします。

$ git add sample.txt
$ git commit