LoginSignup
1
0

More than 5 years have passed since last update.

How to fix コンフリクト

Last updated at Posted at 2018-04-12

前提

- master
- {working_branch}(作業ブランチ)
- masterにworking_branchをmergeさせたいがコンフリクトでできない・・

1. masterを最新状態に更新し作業ブランチにマージ

$ git checkout {working_branch}
$ git pull origin master // ローカルファイルを更新し{working_branch}にmasterをマージ

2. コンフリクト解消

CONFLICT (content): Merge conflict in {conflict_file_name}
Automatic merge failed; fix conflicts and then commit the result.

とでるので{file_name}へ移動しコンフリクト箇所を修正

3. 再びコミットし修正完了

$ git add {conflict_file_name}
$ git commit -m "Fix conflict"
$ git push origin {working_branch}

参考情報

コンフリクト解消するにあたって片方の変更を適用したい時は便利なコマンドがある
- {conflict_file_name_1}: 作業中のブランチの変更を適応したい
- {conflict_file_name_2}: masterブランチの変更を適応したい

$ git checkout --ours {conflict_file_name_1}
$ git checkout --theirs {conflict_file_name_2}
$ git add {conflict_file_name_1} {conflict_file_name_2}
$ git push origin {working_branch}
1
0
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
1
0