I just came to know about this very neat feature of the git status command.Basically, the status command gives you the the names of the files which you are tracking but have certain changes in them relative to your last commit. Now, Git has 3 places in which it keeps the code - the commit area, the stage area/index and the working directory. Lets take a few scenarios to explain the usefulness of this command
Lets say that you have a file called Sample_File.txt in the working directory to which you made a few changes. But you have not staged it yet. So, the state of the file in the three repositories can be described as (latest commit == staged) != (working). To know which files have been modified in the working directory, in a very shorthand form, use git status with the -s option. Here's what I got when I ran it on my system.
Notice that the M is in Red, and there is a little bit space to its left, which means, that the file is modified in your working directory. (The extra space is explained in scenario 2) The status code M stands for 'Modified'. There are many other one letter status codes that you can take a peek at over here.
Lets say that you have a file in your working directory, that has some changes but you staged it after making these changes. In this case the state of the file in the three repositories can be described as (latest commit)! = (staged == working ) Now if you run git status -s, this is what you get
Notice that the M is in Green, but this time there no space to its left, which means, that the file is in a modified state in your staged directory. You can however notice that there is some extra space between the M and the file name this time. (Will be clarified in Scenario 3)
Lets say that your made changes to your file, staged it and then edited it again.
In this case the state of the file in the three repositories can be described as (latest commit ! = staged != working )
Now you can see clearly that you have 2 M's. One in red indicating the state of your file in the staged area and one in green indicating the state of your file in the working directory.
Its quite common that throughout your workflow, you would find yourself moving between the above scenarios sequentially. (Scenario 1 -> Scenario 2 -> Scenario 3) . The above set of commands should be able to help you keep track of what files were changed where.
The git manual reference