I am learning to work with git and I'm playing around with branching. I created a file "test.rb" and committed a version on a 'testing' branch.
Being on 'master' I use git commit -a -m 'msg'
and get this message:
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.rb
nothing added to commit but untracked files present (use "git add" to track)
I cannot understand why, since the '-a' flag should add everything to staging and commit it.
What am I missing? Thanks !
Since the
test.rb
file is not yet tracked by git, you need to add it first usinggit add
git add test.rb
git commit -m "msg"
After that, if you add changes to this file, you can use the -a
option to commit your changes
git commit -am "msg"
This is also highlighted by the description for the -a
flag in git's help:
$ git commit --help
-a, --all
Tell the command to automatically stage files that have been
modified and deleted, but new files you have not told Git about
are not affected.