If we want to commit the tracked files without adding them into staging area git provides a shortcut. We will see how to do it in this post.
First I’ll run ”git status” command to check whether my working directory is clean.
After this I’ll make change in sample.txt and I’ll create new file “second.txt” and again I’ll run “git status” command.
Now here we can see sample.txt is in modified stage and second.txt is in untracked stage. To directly commit them I’ll use following command:
git commit -a -m "commit message here"
Above command gives the following output.
Now if I run git status command it will give me following output:
Here if you see sample.txt is committed successfully, but second.txt is in the untracked stage only, this means git does not commit untracked files, if we try to directly commit with the above command. So in order to commit second.txt, we need to add it to the tracking stage.
We can do it in following way.
Now here we have committed second.txt also.