ベスパリブ

プログラミングを主とした日記・備忘録です。ベスパ持ってないです。

after resolving the conflicts, mark the corrected paths with 'git add <paths>' or 'git rm <paths>' and commit the result with 'git commit'

(他ブランチの)特定コミットをmasterブランチにコミットする。

git checkout master
git cherry-pick [コミットID]

当たり前のようにエラーが出る。

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'

コンフリクトを解消した後、git addかgit rmして正しいパス(ファイル)をマークして、そしてgit commitしてください(マークってなんだよ)。

マージされていないファイルを見る。

git ls-files -u

ls-filesの詳細は以下のサイトが詳しい。
http://transitive.info/article/git/command/ls-files/

現在の状態を見てみる。

git status
...(略)
Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   hogehoge.c
        both modified:   fugafuga.c

hogehoge.cとfugafuga.cを手作業でコンフリクトを解消してやるのが普通のやり方。
でも多くの場合、マージ先かマージ元を優先してコミットをしている。そのときはcheckout --oursまたはcheckout --theirsを使えば一発。
詳細は以下のサイトが詳しい。
http://blog.digital-squad.net/article/151034635.html

今回はマージ元(develop)を優先してマージ先(master)にコミットしたいので、--theirsを使う

git checkout --theirs hogehoge.c
git checkout --theirs fugafuga.c

git statusを見る。

...(略)
Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   hogehoge.c
        both modified:   fugafuga.c

あれ?変わってないじゃん。

とりあえずhogehoge.cの中身をエディタで見てみよう。<<<<<<< HEADがなくなっていることがおかわりだろうか。世界は修正されたのである。

ということでaddしてcommitする。

git add .
git commit

おわりだが、ついでにpushしてリモートリポジトリに反映しておこう。
pushのやり方を忘れた?以下のサイトが詳しい。
http://shoma2da.hatenablog.com/entry/2014/03/08/234523
origin masterよりもorigin master:masterのほうがわかりやすい。省略系って嫌いなんだよね。

git push origin master:master