[git] 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?

This question is related to git git-commit

The answer is


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"

As the name suggests 'untracked files' are the files which are not being tracked by git. They are not in your staging area, and were not part of any previous commits. If you want them to be versioned (or to be managed by git) you can do so by telling 'git' by using 'git add'. Check this chapter Recording Changes to the Repository in the Progit book which uses a nice visual to provide a good explanation about recording changes to git repo and also explaining the terms 'tracked' and 'untracked'.


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"


Make sure you're in the right directory (repository main folder) in your local git so it can find .git folder configuration before you commit or add files.


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


  1. First you need to add all untracked files. Use this command line:

    git add *

  2. Then commit using this command line :

    git commit -a


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