logoalt Hacker News

.gitignore Isn't the Only Way to Ignore Files in Git

101 pointsby FergusArgylltoday at 10:29 AM24 commentsview on HN

Comments

hk1337today at 2:30 PM

~/.config/git/ignore and ~/.config/git/config is the proper place for your global git config and ignore instead of creating a ~/.gitignore_global and changing the config. IMO.

my dotfiles are a lot smaller at the root level taking advantage of the ~/.config/ for a lot more things.

the git exclude isn't used as much because it doesn't get committed to the repository so you'd have to recreate it each time you wanted to use it. that doesn't mean they're bad just why they are not used.

show 1 reply
wpollocktoday at 3:36 PM

One point of clarification: with git, "global" means per-user, not "machine-wide. (I never understood why "--global" wasn't better named, maybe "--user".) That's why these pathnames are in a user's home (the "~" means the current user's home directory).

Machine-wide configuration is called "system" in git, and generally lives under "/etc".

bryancoxwelltoday at 2:07 PM

I use the ever living hell out of .git/info/exclude. Works great for scripts/Makefiles I only want locally and collaborators wouldn’t care about or be able to use.

show 2 replies
judofyrtoday at 2:34 PM

Not sure where I picked up this, but I’ve added this to my global Git ignore:

    attic
That way you can just create an attic directory in any project where you can keep random stuff that should never be committed. I’ve yet to find a repo which actually has such a directory checker in.
show 1 reply
Hendriktotoday at 1:55 PM

This is just a very low-effort regurgitation of this: https://git-scm.com/docs/gitignore

show 3 replies
jeremyscanvictoday at 3:07 PM

I knew about .git/info/exclude and ~/.config/git/ignore but not about git-check-ignore(1). Neat!

uptowntoday at 3:54 PM

Not really news. I worked with dozens of developers who have managed to ignore files in Git.

barbazootoday at 3:16 PM

Exclude sounds like a recipe for sadness.

globular-toasttoday at 3:41 PM

Magit has good support for these other methods. You press <i> and then select if you want the ignore to be shared (.gitignore) or private (.git/info/exclude).

bitvviptoday at 2:52 PM

I still like using gitignore very much