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.
Thanks
For a workaround, either remove
Projects/.projector 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
.gitignoredon top of that). However in the branch you want to checkout, someone has at some point in the pastgit added and committed that file. Since your current copy is not tracked bygit,gitrefuses to overwrite it with the tracked copy, and also refuses togit rm --cachedit, 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…