Cannot checkout, file is unmerged

Naseer picture Naseer · Mar 13, 2014 · Viewed 111.3k times · Source

I am trying to remove the file from my working directory but after using the following command

git checkout file_Name.txt

I got the following error message

error: path 'first_Name.txt' is unmerged

What is that and how to resolve it?

Following is my git status

$ git status
On branch master
You are currently reverting commit f200bf5.
  (fix conflicts and run "git revert --continue")
  (use "git revert --abort" to cancel the revert operation)

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:      first_file.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        explore_california/

no changes added to commit (use "git add" and/or "git commit -a")

Answer

cristianoms picture cristianoms · Aug 10, 2015

If you want to discard modifications you made to the file, you can do:

git reset first_Name.txt
git checkout first_Name.txt