I\'m trying to do a git pull and get the error message:
error: The following untracked working tree files would be overwritten by merge:
You have untracked files in the way of the pull. You can't remove them with git rm --cached
because they are untracked. They don't appear in the index. You need to remove them with plain old rm
This is an opportunity for the 'git clean' command. If you don't care about the untracked files ... git clean -n
to see what will be removed, and git clean -f
to go ahead and rm untracked files.
Add -d to the commands to also operate on directories:
git clean -dn
git clean -df
That file isn't in the current branch yet, so you can't remove it with git rm --cache
. Just use rm
.
As it says in the original error message, that file is untracked. That means git
doesn't know anything about it. Just remove it from the filesystem using rm
. If you care about the contents, just move it somewhere else.
I agree with other posters, the issue is that the file isn't being tracked by git. the command git rm
works on files being tracked. rm will remove the file from your machine. Alternatively you could add the file to your list of ignored files, or file types if that is convenient. You could also use one of the GUI tools like tortoise git to quickly delete all untracked files.