Reputation: 4867
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/)
Upvotes: 0
Views: 149
Reputation: 8810
You've got some files/folders committed in the branch you've got checked out, presumably before you added them to .gitignore.
Remove them from your index using git rm folder\ --cached
and then try again - you shouldn't receive the warning.
Upvotes: 1
Reputation: 174329
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 .gitignore
it already is inside your repository and thus will be checked out, just like all other files.
.gitignore
is 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 command git rm folder/
.
Upvotes: 1