Reputation: 17243
I'm working on a Python project with PyCharm, which includes an .idea
folder in my project.
Because the maintainer of the project doesn't want contributors to edit the project's .gitignore
, I added a .gitignore_global
file to ~/{myuser}
with two lines:
# comment line because git has a bug where sometimes the first line is ignored
.idea/
I ran the command
git config --global core.excludesfile "C:\\Users\\{myuser}\\.gitignore_global"
Running git status
, the following still appears:
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
I tried running both of these commands:
git rm --cached -r .idea/
git update-index --assume-unchanged .idea/
The first results in an error:
fatal: pathspec '.idea/' did not match any files
The second changes nothing.
How can I get git to ignore this folder?
Upvotes: 1
Views: 218
Reputation: 17243
The problem was an unnecessary space character after the directory name I wanted to ignore...
The original global excludes file:
#
.idea/ <--- there's a space here
The fixed one (no space):
#
.idea/
I swear that was the problem... Thanks everyone for your help anyway!
If this helps somebody in the future, I'm using git version 1.9.5.msysgit.1 on Windows 7.
Upvotes: 1
Reputation: 38734
Never ever ever use update-index --asume-unchanged
it will maybe appear to be doing what you want, but you are very more likely risking your files instead.
Your description most likely seems to be a problem with the core.excludesfile
value.
Are you using Git for Windows or Cygwin Git? If the latter you might need to setup the cygwin path, not the windows path.
Alternatively you could also make your excludes in .git/info/excludes
though then they are of course only for this repo, not for all your repos like you tried it.
You can diagnose the result also with the command git check-ignore .idea/ --no-index -v -n
or similar.
Upvotes: 0
Reputation: 2939
File .gitignore
will only effect files that haven't been added already, so is .idea/
in your repo or no?
If your .idea/
folder is tracked yet, do git rm -r --cached path_to_your_folder/
Upvotes: 0
Reputation: 28981
I think the problem is git config --global core.excludesfile "C:\Users\{myuser}\.gitignore_global"
because you are using \
and it is escape character. Try to double it.
Upvotes: 0
Reputation: 105
If Git isn't tracking the folder, it shouldn't appear in github. Have you tried checking the repository to make sure that it actually is uploading? If it is, try moving the .idea folder out of the project, doing a commit, and then putting it back in with the global .gitignore. If the file's changes aren't being tracked, but it's already in the repository, it will stay in the repository. It just won't be updated.
Upvotes: 0