1

I've been trying everything I can think of and I've read all the StackOverflow posts about this issues, yet I can't seem to fix it.

The issue here is that I 1. created a repo (test) , which git is tracking 2. Inside my test folder, I have a .gitignore file 3. I've opened my .gitignore file on sublime which looks like this:

enter image description here

I've tried with and without adding and commiting the .gitignore file on terminal, which doesn't matter both way's since it doesn't work.

When I type git status, I still see the files that need to be commited an the ones that are unstaged.

See my terminal: enter image description here

What am I missing here?

Alex
  • 357
  • 1
  • 12

1 Answers1

2

Replace

* .css

by

*.css

(and same for the other ones)

Relevant documentation

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Unbelievable I didn't see that one myself!! Thank you it works fine now. – Alex Jun 21 '15 at 14:48
  • What about this file:- .DS_Store - It's still showing up to be staged. – Alex Jun 21 '15 at 14:49
  • Just use `.DS_Store`. – JB Nizet Jun 21 '15 at 14:51
  • Works fine here, with `*.DS_Store`and with `.DS_Store`. But the problem is that your .DS_Store has already been commited before, and is thus marked as modified, and not untracked. You'll need to use `git rm` to remove it, then commit. – JB Nizet Jun 21 '15 at 14:59
  • Never mind I got this one. Of course, once a file is tracked in your repository, it will continue to be tracked even if it matches an entry in an applicable .gitignore file. You have to manually remove the .DS_Store files that were added to your repository. You can use git rm --cached .DS_Store. Once removed, git should ignore it. – Alex Jun 21 '15 at 15:00
  • This will however apply it only for this repo. How about if I wanted the .DS_Store not to be staged for any of my repo's? I'm assuming this would be setting it in my config globally. Where do I put this file after creating it so it is applied to all future repo's? – Alex Jun 21 '15 at 15:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/81120/discussion-between-brain-and-jb-nizet). – Alex Jun 21 '15 at 15:16
  • I checked the link you shared and a few things are still unclear to me. I just ran this in my terminal: git config --global core.excludesfile ~/.gitignore_global And it's probably set up now. However I also noticed there is a gist which contains some good rules. Now if I want to add those rules to my .gitignore file (the one that is global), where can I find it? – Alex Jun 21 '15 at 15:32
  • 1
    You need to create the file `~/.gitignore_global` if it doesn't exist yet. `~` is your home directory. Execute `cd` to go home. Then create a file named `.gitignore_global` containing your rules in that directory. – JB Nizet Jun 21 '15 at 16:01
  • Works like charm! I wasn't aware that ~ was my homedirectory. Thanks – Alex Jun 21 '15 at 16:39