Sunday 7 July 2013

[Git] Experimenting with git ls-files. Show ignored files in git.

This post describes, my experiments with git ls-files command.

 In repository, we have files:

.DS_Store (Mac OS X, folder settings file)
.git (Git repository file)
.gitignore (Git ignore file)
ignoredFile (Some file, that should be ignored)
inRepo (File in repository)
untracked (Som untracked file)
staged (Staged file)


This command show us, all committed files and staged files.
$ git ls-files
.gitignore
inRepo
staged


This command show us, all files that are ignored or untracked. Those files are called 'other'.
$ git ls-files --others
.DS_Store
ignoredFile
untracked


This command show us, all others files, without ignored files. Option exclude-standard means that standard git exclusion files are included.
$ git ls-files --others --exclude-standard
untracked


This command show us, all files that are ignored.
$ git ls-files --ignored --others --exclude-standard
.DS_Store
ignoredFile

In my global git ignore file, there is a rule to ignore all .DS_Store files. In my local git ignore file, there is a rule to ignore ignoredFile file.

No comments:

Post a Comment