5
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitでコンフリクトした時 'This branch has conflicts that must be resolved' の対処法

Posted at

はじめに

Gitの操作をしている時に次のようなエラーが起こりマージができなかったので、その対処法を備忘録として残します。
picture_pc_c9fe8a8a18b3774717077e036e3a3cce.png

エラーの状況

ファイルがコンフリクトを起こしているので、解決してくださいとのメッセージ。

対処法

$ git checkout branchA  #プルリクしたローカルブランチ(branchA)に切り替える
$ git fetch origin
$ git merge master #コンフリクトを起こしているファイルが表示される

表示されたファイルを確認すると以下のような状態になっています。

Gemfile.
gem 'carrierwave'
gem 'fog'
現在の変更を取り込む|入力側の変更を取り込む|両方の変更を取り込む|変更の比較
<<<<<<< HEAD
=======
gem 'fog-aws'
>>>>>>> master

gem 'coffee-rails', '~> 4.2'

必要な変更をクリックする。今回は「入力側の変更を取り込む」を選択しました。

$ git add .
$ git commit -m "コンフリクトの修正"
$ git checkout master
$ git merge --no-ff branchA  #コミット画面が開くので「:wq」で抜ける
 Merge made by the 'recursive' strategy.
$ git push origin master

以上の処理でプッシュが完了し無事マージされました。

参考

5
12
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
5
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?