Hacker News new | past | comments | ask | show | jobs | submit login
A Collection of Useful .gitignore Templates (github.com/github)
171 points by gintas on Nov 20, 2010 | hide | past | favorite | 16 comments



I'm of the opinion that artifacts of IDEs an OSes should not be part of a projects .gitignore. After all, different people could be using different environments for development and I really don't see the need for a projects .gitignore to contain the subset of all possible artifacts.

Use .git/info/exclude or a repository independent personal .gitignore for this.

The projects file is for files created by running the code or maybe some unavoidable build artifacts happening in all cases (.o files for example)

I really hate commits with messages like "updating .gitignore for Joe's new IDE"


Some projects like Git itself refuse to add editor droppings like ~ and # to .gitignore. They consider the .gitignore file to be only for things that the build system produces, e.g. *.o and binaries.

If you want to ignore things that your editor adds you should add it in .git/info/excludes, not .gitignore.


I put text editor stuff in my global .gitignore


I think this is why the linked collection has all of the editor specific rules in a separate "Global" subdirectory.


If you are using Django/Python, it might be useful to add *.pyc to your gitignore. These are compiled python files.

Also, if you're developing on a Mac, it would also be useful to add .DS_Store. It's an invisible file, and it just stores some properties of that directory,


I believe these are already covered:

  https://github.com/github/gitignore/blob/master/Python.gitignore

  https://github.com/github/gitignore/blob/master/Global/OSX.gitignore


Yeah, I only looked at the Django gitignore.


It seems like a lot of these should have leading slashes so they only match the root directory and not any file with that name.


Anyone got a good Clojure one?


The one created by Leiningen is pretty good.

    .cake
    pom.xml
    *.jar
    *.war
    lib
    classes
    build


It's interesting that the Java one doesn't list *.jar.


Probably because sometimes you want to check libraries into your project. For custom jars, I'd immagine you'd want to specify their paths exactly, or something like (bin|build)/*.jar


My point is that the Clojure one mentioned in the comment I was replying to does include *.jar.


Can't you exclude all jars by default and add whatever libs you do want to check in? I don't know too much about git, but that is how I would do it in Mercurial. (In Mercurial, if you specify an explicit filename, it overrides .hgignore.)


You can, you just need to use ``git add -f`` otherwise you get an error.


it's more interesting it does not include build/ which in 99% of the cases is something you wan to ignore.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: