1

I created a global git ignore file using this method:

git config --global core.excludesfile ~/.gitignore_global

When I check where the file is it tells me the file is here

$ git config --global core.excludesfile
c:/Users/username/.gitignore_global

But when I check the directory there is no git ignore file.

enter image description here

Vader
  • 6,335
  • 8
  • 31
  • 43
  • 1
    Maybe you should add the file by hand first. – Eric Jan 29 '15 at 11:47
  • I cannot create a file named `.gitignore_global` in windows 7. `You must type a file name` – Vader Jan 29 '15 at 11:49
  • 1
    Then name it as `global.gitignore` – Eric Jan 29 '15 at 11:50
  • So I created the file, but windows thinks it's a text document instead of a `gitignore` file, even though there is no `txt` extension – Vader Jan 29 '15 at 11:54
  • Git will find & read the ignore file according to git configurations. You don't need care what windows could do. – Eric Jan 29 '15 at 11:56
  • @EricWang In that case git is still not using that file. I have 3 lines in my `gitignore` file. git is ignoring my ignore file, kinda – Vader Jan 29 '15 at 11:58
  • I just did a test, it works on linux, no matter the project itself contain a `.gitignore` file or not. – Eric Jan 29 '15 at 12:02
  • 3
    *"When I check where the file is it tells me the file is here"* -- Git doesn't tell you that it found the file. It just tells you that it is configured to use that file as global ignore file. It's up to you to create the file and write the right stuff in it. – axiac Jan 29 '15 at 12:09
  • Furthermore you can files with leading dots in windows. Instead of trying to name the file `.gitignore_global` name it `.gitignore_global.` (the trailing dot is important), windows will remove the trailing dot and your file will be named as desired. – Sascha Wolf Jan 29 '15 at 12:26

2 Answers2

2

You must create this file.

However, Windows Explorer can sometimes be picky about file and folder names, particularly when they start with a .

Fortunately, the command prompt isn't as picky. Navigating to your user's home directory (C:/Users/[username]/) and running the command
echo "" > .gitignore_global

will create the file. You can then use Notepad, Notepad++, Sublime Text or whatever to edit the file.

Likewise, mkdir .DOT will bypass Window Explorer's restriction on folder names as well.

KevinL
  • 1,238
  • 11
  • 28
  • 1
    As I already explained in a comment on the question. It's possible to create files with leading dots in windows. Instead of trying to name the file .gitignore_global name it .gitignore_global. (the trailing dot is important), windows will remove the trailing dot and your file will be named as desired. – Sascha Wolf Jan 29 '15 at 14:30
  • I created the file, added the line `*.tmp` yet untracked `.tmp` files are still showing up in git status. – Vader Jan 29 '15 at 14:35
  • @Vader, is it possible the .tmp files were already added to the index? That is, were they added in a previous commit accidentally? If so, see http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore – KevinL Jan 29 '15 at 17:22
  • @KevinL no git tell me they are untracked. – Vader Jan 29 '15 at 17:59
  • @KevinL now when I get weird thing happening in git. `$ git config --global core.excludesfile` `C:UsersUSERNAMEglobal.gitignore` – Vader Jan 29 '15 at 18:01
  • Did you try rerunning `git config --global core.excludesfile ~/.gitignore_global`? – KevinL Jan 29 '15 at 18:17
1

the command git config --global core.excludesfile <PATH> sets the path of your global ignore file. Git will not created this file for you. You need to create it yourself under the path you specified.

mithrandir
  • 738
  • 1
  • 6
  • 17