Why does git commit -am
not work on my initial commit, but works thereafter?
$ touch test.txt
$ ls -a
. .. .git test.txt
$ git commit -am "Initial commit"
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test.txt
nothing added to commit but untracked files present (use "git add" to track)
$
You have to first git add
your file to the repo. git commit
only commits changes to tracked files, git commit -a
will commit all changes to tracked files. But untracked files will not be committed at any point.
You'll find that even on commits after the initial, if you create a new file it will not be committed with git commit -a
until you git add
it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With