Git Ignore - HollyPony/git-documentation GitHub Wiki

How to hide files on Git.

Table of contents:

Ignore files project

Create a .gitignore file in $PROJECT_PATH then list the excluded paths

Note: .gitignore file can be nested and will be applied only on subfolders (relatively)

Ignore files project only for the user

This .gitignore is named exclude and located at: $PROJECT_PATH/.git/info/exclude

This file will not appear in git status, it's a ghost.

Ignore files for all user project (git --global way)

This Gitignore file should be defined in the global git config located at ~/.gitconfig (maybe empty)

Retrieve the Gitignore file: git config --global core.excludesfile

Define the Gitignore file: git config --global core.excludesfile ~/.gitignore (path and name of ~/.gitignore is editable)

Note: Syntax of .gitconfig file

# [core]
#	    excludesfile = /path/to/user/home/.gitignore

Ignore a file already commit / push

  • git rm fileToIgnore.cobol
  • Add fileToIgnore.cobol to .gitignore
  • Commit / Push

If the file is still here (in staged changes): git rm --cached fileToIgnore.cobol

Test ignored files

TODO

Sources