I have a project under git. In my gitignore file, I have a folder folder/ I don’t want git to care about. The problem, is each time I want to checkout a branch , I am asked to error: The following untracked working tree files would be overwritten by checkout:
error: The following untracked working tree files would be overwritten by checkout:
folder/somefile
folder/subfolder/somefile…
So I moved away the folder/, commited again and then took back the folder/ in my git repo. But why is this message always appearing ? (In my .gitignore, I have a line : folder/)
You are getting this message, because you committed files that are inside
folder/before adding that folder to.gitignore.That means, although you have that folder in your
.gitignoreit already is inside your repository and thus will be checked out, just like all other files..gitignoreis used when checking files in, not when checking them out.If you want to remove
folder/from your git repository, you can do so by issuing the commandgit rm folder/.