top of page

Git Status

In Git "git status" is a command used to see the status of the staging area and working directory. To understand this in more detail let's create a new file index.php & append an existing script myscript3.py.

[root@siddhesh MyProject1]# touch index.php
[root@siddhesh MyProject1]# echo "import re" >> myscript3.py
[root@siddhesh MyProject1]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   myscript3.py
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	index.php
no changes added to commit (use "git add" and/or "git commit -a")
[root@siddhesh MyProject1]# 

As you can see in the above output that appended script myscript3.py is now showing as modified and the newly created file index.php is showing as Untracked because this is a new file and staging doesn't have any information about this file.


By passing the -s flag to "git status," you can obtain this information in a shorter format.

We can see in the above output that there are two columns in front of each modified/newly added file.

The left side column displays the status of the staging area, while the right side column displays the status of the working directory.

As you can see, myscript3.py has a capital M in the right side column, indicating that changes to this file have not yet been staged. Index.php has a question mark (?) in the right and left side columns, indicating that it is a newly created file with no information known to the working directory and staging area. Let's move these files to the staging area and see what happens.

myscript3.py and index.php files have now been staged, and the left column status has been updated with A (Add) and M (Modified), respectively. We can now make the decision to commit these changes to the repository.

"git status -s" will not return any results after a commit because the working directory, staging directory, and repository are all in sync and there are no changes.





Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page