File Classifications in Git
Git classifies your files into three groups:
- Tracked
A tracked file is any file already in the repository or any file that is staged in the index. To add a new file,
somefile
, to this group, run git addsomefile
.- Ignored
An ignored file must be explicitly declared âinvisibleâ or âignoredâ in the repository, even though it may be present within your working directory. A software project tends to have a good number of ignored files. Common ignored files include temporary and scratch files, personal notes, compiler output, and most files generated automatically during a build. Git maintains a default list of files to ignore, and you can configure your repository to recognize others. Ignored files are discussed in detail in The .gitignore File.
- Untracked
An untracked file is any file not found in either of the previous two categories. Git considers the entire set of files in your working directory and subtracts both the tracked files and the ignored files to yield what is untracked.
Letâs explore the different categories of files by creating a brand-new working directory and repository and then working with some files:
$cd /tmp/my_stuff
$git init
$git status
# On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track) $echo "New data" > data
$git status
# On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # data nothing added to commit ...
Get Version Control with Git now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.