Git commit -a "untracked files"?
When I do a git commit -a
, I am seeing the following:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch better_tag_show
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: ../assets/stylesheets/application.css
# modified: ../views/pages/home.html.erb
# modified: ../views/tags/show.html.erb
# modified: ../../db/seeds.rb
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../assets/stylesheets/
# ../views/pages/
What does those untracked files mean? All the changes have been indeed tracked. I don't understand why git is warning me about untracked files here.
EDIT:
Ok I see a lot of confused replies. This is what happens after I git commit -a
this.
# On branch master
nothing to commit (working directory clean)
As you can see, there is NOTHING other than those four files that had changes applied.
My question should be rephrased as follows: Why is git warning me about untracked files when all of the changes in this commit has been tracked?
In other words, is the untracked warning in the git commit message unnecessary?
Solution 1:
For others having the same problem, try running
git add .
which will add all files of the current directory to track (including untracked) and then use
git commit -a
to commit all tracked files.
As suggested by @Pacerier, one liner that does the same thing is
git add -A
Solution 2:
git commit -am "msg"
is not same as git add file
and git commit -m "msg"
If you have some files which were never added to git tracking you still need to do git add file
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.
Source: "git commit -a" and "git add"
Solution 3:
You should type into the command line
git add --all
This will commit all untracked files
Edit:
After staging your files they are ready for commit so your next command should be
git commit -am "Your commit message"
Solution 4:
If you are having problems with untracked files, this 3-line script will help you.
git rm -r --cached .
git add -A
git commit -am 'fix'
Then just git push
Solution 5:
-
First you need to add all untracked files. Use this command line:
git add *
-
Then commit using this command line :
git commit -a