.gitignore keeps your repository sane – some helpful resources

Ignoring files is a great article on GitHub Help. The global gitignore file is mentioned there. In this file you can ignore files in all the git repositories on your machine. There is a very helpful template that will ignore compiled output files from various languages (*.o, *.so, *.dll, *.class) as well as logs, database files, packages and also files generated by the operating system (Yes, I’m looking at you Windows Thumbs.db and Mac .DS_Store!).

The above page also links to the gitignore repository on github. This repo contains a whole bunch of gitignore files for programming languages, build systems, servers, markup languages, content management systems, … There is also a global folder for more your global ignore file (IDEs, text editors, non-git version control, operating systems…).

Reference or use git/github-managed code in your git project

Please note that there seems to be better way to do this since git version 1.8.2 (mentioned in these two stackoverflow answers: here and here). The version from the Ubuntu 12.04 repos is 1.7.9.5 though so I’ll take a different route. The project for this example is the handy node.js multi-platform support layer libuv.

Please note that this example expects you to already have an existing project under git control. If you don’t – simply look up on how to create one using git init or git clone one 🙂


# do a "clean cut" before adding the submodule
git commit

# add libuv to the project
git submodule add https://github.com/joyent/libuv.git libuv
git status

# update the submodule
git submodule init
git submodule update

# enforce the version we want to use (tag v0.10.22)
cd libuv/
git reset --hard v0.10.22
cd ..
git commit -a

git submodule status

You can now reference/include the files of the submodule while still being able to update the submodule to newer versions. Gotta love version control!