TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Git Status

Git Status with Git Tutorial, Git Introduction, Git, What is Git, GitHub, What is GitHub, Git vs GitHub, Git Mercurial, Installation of Git for Windows, Installation Git for Ubuntu, Git Environment Setup, Git Command Line Tools, Git Tools, etc.

<< Back to GIT

Git Status

The git status command is used to display the state of the repository and staging area. It allows us to see the tracked, untracked files and changes. This command will not show any commit records or information.

Mostly, it is used to display the state between Git Add and Git commit command. We can check whether the changes and files are tracked or not.

Let's understand the different states of status command.

Status when Working Tree is cleaned

Before starting with git status command, let's see how the git status looks like when there are no changes made. To check the status, open the git bash, and run the status command on your desired directory. It will run as follows:

$ git status

Output:

Git Status

Since there is nothing to track or untrack in the working tree, so the output is showing as the working tree is clean.

Status when a new file is created

When we create a file in the repository, the state of the repository changes. Let's create a file using the touch command. Now, check the status using the status command. Consider the below output:

Git Status

As we can see from the above output, the status is showing as "nothing added to commit but untracked files present (use "git add" to track)". The status command also displays the suggestions. As in the above output, it is suggesting to use the add command to track the file.

Let's track the file and will see the status after adding a file to the repository. To track the file, run the add command. Consider the below output:

Git Status

From the above output, we can see that the status after staging the file is showing as "changes to be committed".

Before committing blindly, we can check the status. This command will help us to avoid the changes that we don't want to commit. Let's commit it and then check the status. Consider the below output:

Git Status

We can see that the current status after committing the file is clean as it was before.

Status when an existing file is modified

Let's check the status when an existing file is modified. To modify file, run the echo command as follows:

$ echo "Text"> Filename

The above command will add the text to the specified file, now check the status of the repository. Consider the below output:

Git Status

We can see that the updated file is displayed as untracked files. It is shown in red color because it is not staged yet. When it will stage, its color will change to Green. Consider the below output:

Git Status

Status when a file is deleted

Let's check the status when a file is deleted from the repository. To delete a file from the repository, run the rm command as follows:

$ git rm < File Name>

The above command will delete the specified file from the repository. Now, check the status of the repository. Consider the below output:

Git Status

The current status of the repository has been updated as deleted.


Next TopicGit Branch




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf