when I try to git add my files, I typed
git add <insert file names here>
That works correctly. However, when I try to do
git commit -a
My git repository tells me that it's empty. What is outputted is:
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
<insert name of files here>
nothing added to commit but untracked files present (use "git add" to track)
Might anyone know the solution to this? Thanks.
And you may also want to make sure you're in the root of your project. I had that problem for a while on a Rails project a while back & then realized I was in the /config
directory. Whoops! #noobmistake
The -a
flag to git commit
overwrites your staging area ("index"). Look at what the man page says:
-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.
A rule of thumb is to use a plain git commit
when you have used git add
. The command git commit -a
is for when you want to commit every change in the repository but can't bother to git add
them.
PS. git add -A
is useful: it adds all non-ignored new files in your working tree
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.