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 but untracked ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access