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?
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.
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.
To fix this error, either add the files causing the error to the staging area or ignore them using the . gitignore file.
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`.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With