Skip to content

setup_gitignore

Florian Schneider edited this page Oct 7, 2014 · 1 revision

Ignore files for version control using .gitignore

In the root directory of your git repository, you can anytime create a file called .gitignore. It is a simple list of criteria for files or directories that will be ignored when you stage files to your next commit. You can easily ignore a file by adding

filename.pdf

to your .gitignore. You can exclude all files of a type, e.g. .pdf files, in all sub-directories by specifying

**/*.pdf

and you can include a particular file that would be ignored because of other criteria by adding it:

!filename.pdf

Having a nicely specified .gitignore keeps your repository slim and clean. Here are some tricks:

Raw data

Particularly for large simulations, including the raw data into the version control can make your repository explode. Therefore, I keep all my raw results in sub-directories called results and add the following to my .gitignore:

**/results

As a consequence, raw results need to be back-uped manually, e.g. always keep a copy on the workstation.

Binary files

Most modern file types are saved as binary and are not well suited for version control, e.g. images, .pdf, .doc & .docx, .xls, .indd (Indesign) & .psd (Photoshop). You can exclude them from version control by adding the following to .gitignore:

# images
**/*.jpg
**/*.gif
**/*.pdf
**/*.eps
**/*.png
**/*.ps

# MS Office
**/*.doc
**/*.docx
**/*.xls

# OpenOffice
**/*.odt

# Indesign files
**/*.indd
**/*.idlk  

# Photoshop files
**/*.psd

I keep a folder called figures in my repository, where I put final .pdf's that I want to put under version control. Iny my .gitignore, I specified:

!figures/*

However, if you collaborate on a particular file or want to save its current status, you can anytime force add it to the next commit.

Auxiliary files

In LaTeX, during the compilation of a pdf file, many auxiliary files need to be generated. Versioning them is entirely useless.

# Texniccenter generated files
**/*.tcp
**/*.tps

# LaTeX help files
**/*.aux
**/*.glo
**/*.idx
**/*.log
**/*.toc
**/*.ist
**/*.acn
**/*.acr
**/*.alg
**/*.bbl
**/*.blg
**/*.dvi
**/*.glg
**/*.gls
**/*.ilg
**/*.ind
**/*.lof
**/*.lot
**/*.maf
**/*.mtc
**/*.mtc1
**/*.out
**/*.synctex.gz
**/*.synctex

Clone this wiki locally