LoginSignup
4
0

More than 3 years have passed since last update.

error: You have not concluded your merge

Posted at

事象 : git pullしたら怒られた

  • 環境
    • Windows10 Pro バージョン1909
    • git version 2.25.0.windows.1
$ git pull
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
こうなるまでの経緯は...
# 1. プルしないでローカルを変更してコミットした
$ git commit -m 'プルしないでローカルを変更してコミットした'
#...省略...

# 2. プッシュしようとしたらプルしろって怒られた
$ git push
To https://github.com/username/repo.git
 ! [rejected]          feature/braname -> feature/braname (fetch first)
error: failed to push some refs to 'https://ponsuke:keyval@github.com/username/repo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

# 3. だからフェッチしたらリモートに変更があった
$ git fetch --all --prune
Fetching origin
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
#...省略...

# 4. プルしたらマージが発生して、
$ git pull
hint: Waiting for your editor to close the file...

# 5. コメント用にエディタが開いたが、うっかりそのエディタを閉じてしまった・・・
$

# 6. 再びプルすると怒られた
$ git pull
error: You have not concluded your merge (MERGE_HEAD exists).
#...省略...

原因 : コミットしていないマージがあるから

メッセージのざっくり訳
エラー:マージが完了していません(MERGE_HEADが存在します)。
ヒント:マージする前に変更をコミットしてください。
fatal:マージが完了していないため終了します。

対応 : マージをリセットする

ちょっとよくわかんなくなったので、取り敢えずマージをリセットしてやり直すことにした

マージをリセットする
$ git reset --merge
プルからやり直す
# 再びプルしてエディタでマージコメント書いて
$ git pull
hint: Waiting for your editor to close the file... error: There was a problem with the editor '"C:\apps\Sublime Text 3\sublime_text.exe" -w'.
Not committing merge; use 'git commit' to complete the merge.
Merge made by the 'recursive' strategy.
#...省略...

# コミットしろとメッセージにあるのでコミットして
$ git commit
On branch feature/braname
Your branch is ahead of 'origin/feature/braname' by 2 commits.
#...省略...

# プッシュしていないコミットがマージ分と自分の変更の2つあることを確認して
$ git log origin/feature/braname..feature/braname
commit b9... (HEAD -> feature/braname)
Merge: e2... e5...
#...省略...

commit e2...
#...省略...

# プシュる
$ git push
Enumerating objects: 16, done.
Counting objects: 100% (14/14), done.
#...省略...
4
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
4
0