I’ve heard or read too many git blog posts/pod casts state that if you create a new file in your local Git repo and you want to shorten the steps on getting it added to the local repository, all you have to do is:
| |
This is not true. If the file has never been added to the repo prior, then you still have to:
| |
Why?
The “git commit -a” command is a shortcut to a two-step process. After you modify a file that is already known by the repo, you still have to tell the repo, “Hey! I want to add this to the staged files and eventually commit it to you.” That is done by issuing the “git add” command. “git commit -a” is staging the file and committing it in one step.
If you create a new file, edit it, and issue the “git commit -a” command, you will see something like:
| |
The “nothing added to commit but untracked files present” is the key comment. Git even suggests using “git add” to track the file. See, it’s user friendly. Just be aware.