Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot checkout, file is unmerged

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") 
like image 255
Naseer Avatar asked Mar 13 '14 17:03

Naseer


People also ask

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

To fix the “pulling is not possible” error, you can use git reset –hard. Always write a commit message after adding a file to Git's history. Ensure your files are updated to avoid conflict when pulling changes. You need to commit your changes or stash them before you can merge.


2 Answers

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

git reset first_Name.txt git checkout first_Name.txt 
like image 101
cristianoms Avatar answered Oct 05 '22 08:10

cristianoms


To remove tracked files (first_file.txt) from git:

git rm first_file.txt 

And to remove untracked files, use:

rm -r explore_california 
like image 41
brokenfoot Avatar answered Oct 05 '22 08:10

brokenfoot