Tutoriels‎ > ‎totoriel git‎ > ‎

gitignore

Il est inutile et même incorrecte de placer les fichiers binaires dans un dépot de code pour y parvenir vous devez ajouter un .gitignore à votre dépot

.gitignore

If you create a file in your repository named .gitignore git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename

This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository.

Note that you can create a .gitignore in any subpath to have its rules applied at that path. Sometimes an empty .gitignore file is used as a placeholder for an empty path, for example to force git to generate a log/ path for your development environment to use.

GitHub maintains an official list of recommended .gitignore files at this public repository.

Global .gitignore

A global .gitignore file can also be very useful for ignoring files in every git repositories on your computer. For example, you might create the file at ~/.gitignore_global and add some rules to it. To add this file to your cross-repository configuration, run git config --global core.excludesfile ~/.gitignore_global

Here are some good rules to add to this file:

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

You may also want to check out GitHub's gitignore repository, which contains a list of .gitignorefiles for many popular operating systems, environments, and languages.

Repository exclude

Local per-repository rules can be added to the .git/info/exclude file in your repository. These rules are not committed with the repository so they are not shared with others. This method can be used for locally-generated files that you don't expect other users to generate, like files created by your editor.

Ignoring versioned files

Some files in a repository, which are versioned (_i.e._ they can't be git-ignored), are often changed, but rarely committed. Usually these are various local configuration files that are edited, but should never be committed upstream.

Git lets you ignore those files by assuming they are unchanged. This is done by running thegit update-index --assume-unchanged path/to/file.txt command. Once marking a file as such, git will completely ignore any changes on that file; they will not show up when runninggit status or git diff, nor will they ever be committed.

To make git track the file again, simply run git update-index --no-assume-unchanged path/to/file.txt.

Comments