Pregunta

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")
¿Fue útil?

Solución 2

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

git rm first_file.txt

And to remove untracked files, use:

rm -r explore_california

Otros consejos

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

git reset first_Name.txt
git checkout first_Name.txt

Following worked for me

git reset HEAD

I was getting the bellow 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

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.

I don't think execute

 git rm first_file.txt

is a good idea.

  1. when git notice your files is unmerged, you should ensure you had committed it.

  2. And then open the conflict file:

    cat first_file.txt

  3. fix the conflict

4.

git add file

git commit -m "fix conflict"

5. git push

it should works for you.

Step 1:

git stash -u

Step 2:

git stash drop stash@{1}

Step 3:

git checkout .

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.

i resolved by doing below 2 easy steps :

step 1: git reset Head step 2: git add .

It works for me.

It will recover file from curreny HEAD

    git restore -S -W file_Name.txt
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top