Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commit -a "untracked files"?

Tags:

git

git-commit

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?

like image 538
disappearedng Avatar asked Dec 12 '11 06:12

disappearedng


People also ask

Does git commit untracked files?

Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit), and which hasn't yet been staged; Git won't start including it in your commit snapshots until you explicitly tell it to do so.

How do I commit an untracked file?

You have to add the untracked files of the repository by using the “git add” command and run the “git stash” command to save the untracked file and clean the current directory for working by removing the untracked file from the repository folder.

How do I fix nothing added to commit but untracked files?

To fix this error, either add the files causing the error to the staging area or ignore them using the . gitignore file.

Does commit add untracked files?

It does commit deletions. It doesn't commit untracked files. If you really want to track every new file unprompted, an alias can be made for `git add --all && git commit`.


1 Answers

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

like image 90
coding_idiot Avatar answered Oct 08 '22 16:10

coding_idiot