1

I'm having troubles to resolve a problem I have on my working copy: earlier I pulled and it auto-merged a couple of files, they showed then up in the staged area from where I did not commit. I reverted the changes in the files by git checkout -- my/file now, later in the day, I wanted to do another pull but it can't, I got an error like:

$ 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.

how can I fix the situation? I don't want to commit anything on this branch! I also get:

$ git status
On branch dev
Your branch and 'origin/dev' have diverged,
and have 3 and 4 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
BitFreak
  • 406
  • 3
  • 10
  • 1
    `git pull` means *run two Git commands: first, run `git fetch`, then run a second Git command.* The *second* command defaults to `git merge`. If you ran `git pull` earlier, it probably already ran `git merge` (depending on whether you changed the second command for your `git pull`). This is probably the reason you're still in the middle of a conflicted merge. You must either finish this merge, or abort it, before you can do another `git pull`. – torek May 07 '20 at 02:43
  • (You might be best served by working through a good Git tutorial. Git is notoriously beginner-hostile, and you're right in the middle of one of these things right now.) – torek May 07 '20 at 02:46

1 Answers1

2

First, a git merge --quit (Git 2.23+) should help get rid of the merge in progress.

Second, git pull --rebase should help replaying your local commits on top of an updated origin/dev.

Then you can push.

The OP BitFreak made it work (see comment) with:

git push --abort
git pull --rebase
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • the right command is `git merge --abort`, `git pull --rebase` resolved the issue as desired! Great, thanks! – BitFreak May 07 '20 at 18:57
  • 1
    @BitFreak Great. I have included your comment in the answer for more visibility. – VonC May 07 '20 at 19:40