Chapter 3. Making Commits
This chapter explains how to make changes to your repository content: add, edit, and remove files; manipulate the index; and commit changes.
Changing the Index
When you run git commit, without arguments or options, Git adds the contents of the index as a new commit on the current branch. So before committing, you add to the index those changes you want to commit. This can skip some changes you’ve made to your working files, if you’re not ready to commit those yet.
git commit <filename>
Giving a specific filename to git commit works differently: it ignores the index, and commits just the changes to that file.
Adding a New File
$ git add filenameThis is suitably mnemonic, but note the next command.
Adding the Changes to an Existing File
$ git add filenameYes, this is the same command. In both cases, Git adds the current working file contents to the object database as a new blob-type object (assuming it’s not already there), and notes the change in the index. If the file is new, then this will be a new index entry; if not, just an updated one pointing to the new object (or with changed attributes, such as permissions)—but it’s essentially the same operation to Git. A file is “new” if its pathname is not in the index, usually meaning it was not part of the last commit; this is what causes git status to note a file as “untracked” prior to your adding it (files in the index are called “tracked,” and they are the ones Git cares about, generally speaking).
The filename ...