Cannot perform git pull

I am trying to do git pull and get an error message:

error: The following untracked working tree files would be overwritten by merge: <myFileName> Please move or remove them before you can merge. 

So, I am trying to delete a file using the git rm --cache command , which results in an error:

 fatal: pathspec <myFileName> did not match any files 

At this moment I am stuck. I cannot pull until I delete the file. But, this tells me that I cannot delete the file.

What can I do to fix this?

+49
git
May 08 '13 at 18:28
source share
5 answers

You have unprepared files in the traction path. You cannot delete them with git rm --cached because they are not tracked. They do not appear in the index. You need to delete them using regular old rm

+21
May 08 '13 at 18:34
source share

This is an opportunity for the git clean command. If you don't care about unverified files ... git clean -n to see what will be removed, and git clean -f to continue and rm untracked files.

Add -d to commands that will also work with directories:

  git clean -dn git clean -df 
+95
May 05 '15 at 1:10
source share

This file is not yet in the current branch, so you cannot delete it with git rm --cache . Just use rm .

+4
May 08 '13 at 18:30
source share

I agree with the other posters, the problem is that the file is not tracked by git. The git rm command works with tracked files. rm will delete the file from your computer. Alternatively, you can add the file to the list of ignored files or file types, if convenient. You can also use one of the GUI tools, such as the git turtle, to quickly delete all unprocessed files.

+4
May 08, '13 at 19:12
source share

As the original error message says, this file is not tracked. That means git doesn't know anything about this. Just remove it from the file system using rm . If you care about the content, just move it to another location.

+2
May 08 '13 at 18:34
source share



All Articles