Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merge error "commit is not possible because you have unmerged files"

Tags:

git

git-merge

People also ask

How do you fix committing is not possible because you have unmerged files?

hint: Fix them up in the work tree, and then use 'git add/rm <file>' hint: as appropriate to mark resolution and make a commit.

Is it possible to unmerged files git?

Git Pull is Not Possible, Unmerged Files.


If you have fixed the conflicts you need to add the files to the stage with git add [filename], then commit as normal.


You need to do two things. First add the changes with

git add .
git stash  

git checkout <some branch>

It should solve your issue as it solved to me.


You can use git stash to save the current repository before doing the commit you want to make (after merging the changes from the upstream repo with git stash pop). I had to do this yesterday when I had the same problem.


This error occurs when you resolve the conflicts but the file still needs to be added in the stage area. git add . would solve it. Then, try to commit and merge.


Since git 2.23 (August 2019) you now have a shortcut to do that: git restore --staged [filepath]. With this command, you could ignore a conflicted file without needing to add and remove that.

Example:

> git status

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

> git restore --staged file.ex

> git status

  ...
  Changes not staged for commit:
    (use "git add <file>..." to update what will be committed)
    (use "git restore <file>..." to discard changes in working directory)
      modified:   file.ex


I've had a similar issue which boiled down to removing files under "unmerged paths"

Those files had to be removed using git rm