Understanding file states in Git

In Git, every file can be in one of two generic states: tracked and untracked.

Initially, all files exists in the workspace (also known as working tree or working directory) and are in the untracked state. These untracked files are not part of the repository, and Git won't pick up changes made to them. When we run git status, Git sees that there are files in our workspace that are untracked (not part of the repository) and asks whether we want to add them to the repository. When we commit a new file to the repository using git add and git commit, it transitions from untracked to tracked:

$ git add README.md
$ git commit -m "Initial commit"
[master (root-commit) 6883f4e] Initial commit
1 file changed, 1 insertion(+)
create mode 100644 README.md

README.md is now part of the repository and is in the tracked state.

We are passing in   "Initial commit"  as a comment that describes the commit. Every commit should have an accompanying message that describes what changes were made. It should be informative and specific; for example,   "Fixed rounding error bug in calculateScore"  is a better commit message than   "fixed bugs".

However, since our commit does little other than initializing the repository, this message will suffice.

We can confirm this by looking at the Git commit history of the repository with the git log command:

$ git log
commit 9caf6edcd5c7eab2b88f23770bec1bd73552fa4a (HEAD -> master)
Author: Daniel Li <dan@danyll.com>
Date: Fri Dec 8 12:29:10 2017 +0000
Initial commit