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")
To remove tracked files (first_file.txt) from git:
git rm first_file.txt
And to remove untracked files, use:
rm -r explore_california
If you want to discard modifications you made to the file, you can do:
git reset first_Name.txt
git checkout first_Name.txt
status tell you what to do.
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
you probably applied a stash or something else that cause a conflict.
either add, reset, or rm.
Following is worked for me
git reset HEAD
I was getting following error
git stash
src/config.php: needs merge
src/config.php: needs merge
src/config.php: unmerge(230a02b5bf1c6eab8adce2cec8d573822d21241d)
src/config.php: unmerged (f5cc88c0fda69bf72107bcc5c2860c3e5eb978fa)
Then i ran
git reset HEAD
it worked
I don't think execute
git rm first_file.txt
is a good idea.
when git notice your files is unmerged, you should ensure you had committed it.
And then open the conflict file:
cat first_file.txt
fix the conflict
4.
git add file
git commit -m "fix conflict"
5. git push
it should works for you.
In my case, I found that I need the -f option. Such as the following:
git rm -f first_file.txt
to get rid of the "needs merge" error.
ReferenceURL : https://stackoverflow.com/questions/22386030/cannot-checkout-file-is-unmerged
'programing' 카테고리의 다른 글
How to set include path in xcode project (0) | 2021.01.17 |
---|---|
Spring Bean Scopes (0) | 2021.01.17 |
Conditional with statement in Python (0) | 2021.01.17 |
Keep Text From Wrapping in Bootstrap 3 Responsive Design (0) | 2021.01.17 |
Are doubles faster than floats in C#? (0) | 2021.01.17 |