How to resolve git status "Unmerged paths:"?

195,060

Solution 1

All you should need to do is:

# if the file in the right place isn't already committed:
git add <path to desired file>

# remove the "both deleted" file from the index:
git rm --cached ../public/images/originals/dog.ai

# commit the merge:
git commit

Solution 2

Another way of dealing with this situation if your files ARE already checked in, and your files have been merged (but not committed, so the merge conflicts are inserted into the file) is to run:

git reset

This will switch to HEAD, and tell git to forget any merge conflicts, and leave the working directory as is. Then you can edit the files in question (search for the "Updated upstream" notices). Once you've dealt with the conflicts, you can run

git add -p

which will allow you to interactively select which changes you want to add to the index. Once the index looks good (git diff --cached), you can commit, and then

git reset --hard

to destroy all the unwanted changes in your working directory.

Share:
195,060

Related videos on Youtube

keruilin
Author by

keruilin

Updated on October 20, 2020

Comments

  • keruilin
    keruilin over 3 years

    I merged branch dog into animal. When I go to commit, I get the following:

    Unmerged paths:
    (use "git reset HEAD <file>..." to unstage)
    (use "git add <file>..." to mark resolution
    both deleted:       ../public/images/originals/dog.ai
    added by them:      ../public/images/original_files/dog.ai
    

    I had different directory names and file names in each branch. The animal branch has the changes that I want.

    When I go to reset the head, it doesn't work. And when I go to take any other git action (remove, checkout, etc), I get a path not found error.

    What commands do I need to execute to resolve this?

  • Saikat
    Saikat almost 7 years
    What is "Updated upstream" notices?
  • naught101
    naught101 almost 7 years
    @takias: the markers in each file that look like: <<<<<<< [branch] \n [content] \n ==== \n [content] \n [branch] >>>>>>>. I think the format may have chanced slightly since I wrote this, but see wincent.com/wiki/Git_merge_conflict_cheatsheet for an example.
  • Francisco Ochoa
    Francisco Ochoa over 6 years
    further explanation would come in handy
  • Tomáš Hübelbauer
    Tomáš Hübelbauer about 2 years
    If you just want to get out of the merge mode without resolving anything, git reset as mentioned in another answer, is a better option.
  • Thomas
    Thomas almost 2 years
    Will git reset remove untracked files?