When I do a git commit -a
, I am seeing the following:
# Please enter the commit message for your changes. Lines starting
# with \'#\' will
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.
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"
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
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
First you need to add all untracked files. Use this command line:
git add *
Then commit using this command line :
git commit -a