Types of files status in GIT and viewing status of files and difference in them.

Files in a local GIT repository can be in 4 status :
a. Untracked : These files are newly added into the repository.
b. Unmodified : These files exist in repository and local and both have same content.
c. Modified : These files exist in repository and local but some changes are made to the local copy of the file.
d. Staged : These files exist in repository and local but some changes are made to the local copy of the files and the files has been added to the staging area using git add <file_name> command. These file will go with the next commit made to the repository

Status of GIT files can be viewed using below commands

git status
git status -s
#to see the time taken to check status
time git status


So there are different stages files in GIT for example below

Command : git status -s
  1. File f1.txt is modified but not yet staged hence M in the right column with read color
  2. File f2.txt is modified and added to the staging area hence M in the left column with green color
  3. File f3.txt was modified and added to the staging area but after that again there was modification done to f3.txt this time it was not added into staging are. If we commit f3.txt now GIT will only commit that version of file which was added to the staging area, the modified version of f3.txt will not be committed
  4. File f5.txt was a completely new file, it was created and added to the staging are hence A in the left column with GREEN color signifying it a newly added file
  5. File f4.txt displays ?? in the left and the right column which signifies it is an untracked file which is not present in the repository nor added into git staging area.

Now the same set of status can be viewed as a complete version with command git status, below is the screenshot of how it looks.

Command : git status

GIT diff

If git status command is not enough for you and you want to find out what content of the files has been changed then you can do that using git diff

git diff command compares the committed files with the files that are not yet added to the staging area, if you want to compare the committed files with the staging area you need to run the command git diff command with —staged attribute, example below

Now can check what you have staged so for using the command git diff –cached

git diff --cached

Leave a Comment