git fatal: when trying git rm –cached
Hi When trying to switch between branch, I have a error:
error: The following untracked working tree files would be overwritten by checkout: Project/.project Please move or remove them before you can switch branches.
but when I try to use
git rm --cached Project/.project
I get a error:
fatal: pathspec 'Project/.project' did not match any files
Please suggest a work a round, Any way some of the files might be moved is some of the branches and the added a gain, and please explaine the two errors.
One Solution collect form web for “git fatal: when trying git rm –cached”
For a workaround, either remove
Projects/.project or save it somewhere outside your repository if you need to keep it.
What is happening is your current work tree on your current branch has this file, but you are not tracking it (and maybe it’s
.gitignored on top of that). However in the branch you want to checkout, someone has at some point in the past
git added and committed that file. Since your current copy is not tracked by
git refuses to overwrite it with the tracked copy, and also refuses to
git rm --cached it, because it doesn’t know anything about it. This is in general a good thing. However, you might need to evaluate whether this file needs to be tracked, and if not, perhaps it needs to be purged from that other branch…