The Wayback Machine - https://web.archive.org/web/20240910072849/https://www.geeksforgeeks.org/git-status/
Open In App

Git – Status

Last Updated : 22 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Git is a powerful version control system that helps you to manage code changes and collaborate efficiently. One of the fundamental commands in Git is git status, which provides important information about the current state of your working directory and staging area. This article will explain the git status command, its output, and how to use it to effectively manage your Git workflow.

What is the git status Command?

The git status command is used to display the state of the working directory and the staging area. It shows which changes have been staged, which have not, and which files are not being tracked by Git. This command is important for understanding the current status of your project and for making informed decisions about your next steps.

To use the git status command, navigate to your Git repository in your terminal and type:

git status

This command does not require any arguments, and its output provides a snapshot of your repository’s status.

Creating a project folder and Initializing Git

$ mkdir gfg
$ cd gfg
$ git init

Output:

Git Status when working tree is clean:

$ git status

Output:

Here, the Working tree is clean that’s why the output is coming as nothing to commit.

Git Status when a new file is created:

$ touch new.txt
$ git status

Output:

Here, We created a new file that’s why it is showing untracked files. We can use the ‘git add’ command to include this file.

$ git add new.txt
$ git status

Output:

Now, It is showing changes to be committed which means the file is now included and ready to commit. We can commit files using the git commit -m “message” command.

$ git commit -m "first commit"
$ git status

Output:

After committing, the status is now changed to nothing to commit because now the working tree is clean.

Git Status when an existing file is modified:

First, we need to add some content to our new.txt file.

Now execute command i.e.

$ git status

Output:

It is showing modified: new.txt means something is modified in it. Now let’s add it and commit it.

$ git add new.txt
$ git commit -m "file modified"
$ git status

Output:

After adding and committing our working tree is cleaned that’s why git status is showing ‘nothing to commit’.

Git Status when the file is deleted:

$ git rm new.txt
$ git status

Output:

After deleting the file git status command show’s the deleted file name and it is also ready to commit it by using the git commit command. So let’s commit it and then see the status of the repo.

$ git commit -m "file deleted"
$ git status

Output:

After committing our working tree is cleaned that’s why git status is showing ‘nothing to commit‘.


Previous Article
Next Article

Similar Reads

Difference Between Git remote prune, Git prune and Git fetch --prune
Git is a version control system that helps developers manage and track changes in their codebase. Among its many commands, git remote prune, git prune, and git fetch --prune are essential for maintaining a clean and organized repository. This article will explain the differences between these commands, their syntax, uses, and provide examples to il
4 min read
Git - git-show Command Line Utility
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it that may be
3 min read
Git LFS: Managing Large Files in Git Repositories
Git, undoubtedly one of the most popular version control systems, is widely used for managing source code in software development projects. However, one of its limitations is its handling of large files. Traditional Git repositories struggle to efficiently manage large files, leading to bloated repositories and slow performance. This is where Git L
4 min read
Git Subtree vs. Git Submodule
Git Subtree and Git Submodule are both mechanisms in Git that allow you to incorporate external repositories into your own repository. They provide a way to manage dependencies and include code from other projects while keeping your repository organized and maintainable. Git Subtree: Git Subtree allows you to insert a separate repository as a subdi
4 min read
Difference Between Git Push Origin and Git Push Origin Master
Understanding the difference between git push origin and git push origin master is important for efficient version control in Git. These commands are used to upload changes from your local repository to a remote repository, but they function differently. This article will explain these differences, how each command works, and when to use them. What
3 min read
How to Set Up Git Using Git Config?
Git is a powerful version control system that helps developers manage and track changes in their code. Setting up Git correctly is important for maintaining an organized and efficient workflow. In this article, we'll walk you through the process of setting up Git using the git config command. PrerequisitesBefore we dive into the setup process, make
3 min read
How To Exit Git Log or Git Diff?
When working with Git, the git log and git diff commands are important for viewing commit history and changes between commits, respectively. However, if you're new to Git, you might find yourself stuck in these views, unsure how to exit. This article will guide you through the steps to exit git log or git diff, ensuring a smooth experience while na
2 min read
Git - git prune
Git is a powerful version control system that helps developers manage their code efficiently. However, as your project evolves, you may accumulate unnecessary data that clutters your repository. This is where git prune comes in view. What is git prune?git prune is a Git command that removes objects that are no longer referenced by any branch or tag
5 min read
Difference between “git add -A” and “git add”
When working with Git, the git add command is used to move changes from your working directory to the staging area. However, there are different options and flags that can be used with git add, such as -A, which might lead to some confusion. In this article, we'll explore the differences between git add -A and git add. 1. Git add- CommandThe git ad
2 min read
Git - Difference Between Git Revert, Checkout and Reset
Git offers a range of commands to manage and manipulate your codebase. Among these commands, git revert, git checkout, and git reset are frequently used for different purposes. Understanding the differences between these commands is important for effective version control. In this article, we'll explore the functionalities and use cases of git reve
6 min read
How to Fix Git Error "Unable to create '/path/my_project/.git/index.lock'"?
The Git error "Unable to create '/path/my_project/.git/index.lock'" typically occurs when Git is unable to create or write to the index.lock file. This file is used to prevent simultaneous processes from modifying the repository, which could lead to corruption. Table of Content Remove the Lock File ManuallyUse Git Command to Remove the Lock FileRes
2 min read
Difference Between "git commit" and "git push"?
Git commit and git push are two essential commands you'll use a lot when working with Git. even their frequent use together, they have different functions. In order to help you understand when and how to use these two commands effectively in your version control workflow, this article will break down their differences. What is git commit?git commit
2 min read
Difference Between Git Fetch and Git Pull
Understanding the difference between git fetch and git pull is important for effective version control in Git. Git Fetch and Git Pull are two important commands in Git that help in managing remote repositories. While both commands involve retrieving data from remote repositories, they serve distinct purposes and are used in different contexts. In t
5 min read
HTML | DOM Window status Property
The Window status property in HTML DOM is used to set or return the text in the status bar at the bottom of the browser. Syntax: window.status Note: This property has been DEPRECATED and is no longer recommended. Return Value: It returns a string which represents the text displayed in the status bar. Example 1: This example use window status proper
2 min read
HTTP status codes | Successful Responses
The HTTP status codes are used to indicate that any specific HTTP request has successfully completed or not. The HTTP status codes are categorized into five sections those are listed below: Informational responses (100–199) Successful responses (200–299) Redirects (300–399) Client errors (400–499) Server errors (500–599) There are ten Successful Re
4 min read
HTTP status codes | Informational Responses
The HTTP status codes are used to indicate that any specific HTTP request has successfully completed or not. The HTTP status codes are categorized into five sections those are listed below: Informational responses (100–199) Successful responses (200–299) Redirects (300–399) Client errors (400–499) Server errors (500–599) There are four Informationa
2 min read
HTTP status codes | Redirection Responses
HTTP status codes are a conversation between your browser and the site server. The server gives responses to the browser's request in the form of a three-digit code known as HTTP status codes. The HTTP status codes are categorized into five sections which are listed below. Informational responses (100–199) Successful responses (200–299) Redirects (
2 min read
HTTP status codes | Server Error Responses
HTTP status codes is a conversation between your browser and the site server. The server gives responses to the browser's request in the form of a three-digit code known as HTTP status codes. Categories of HTTP status codes are. Informational responses (100–199) Successful responses (200–299) Redirects (300–399) Client errors (400–499) Server error
3 min read
How to create Covid19 Country wise status project using REST API ?
Today, All Countries in the world fighting with Coronavirus. Every day, Coronavirus cases rising rapidly. It is important for all to keep track of COVID Cases daily and should try to keep himself/herself safe. We have made small web apps that will tell you the total no of cases, new cases, new death, recovery, etc. to the user. You have to just ent
7 min read
HTTP status codes | Client Error Responses
The browser and the site server have a conversation in the form of HTTP status codes. The server gives responses to the browser’s request in the form of a three-digit code known as HTTP status codes. The categorization of HTTP status codes is done in five sections which are listed below. Informational responses (100–199)Successful responses (200–29
4 min read
ASP Status Property
The ASP Status Property is used to specify the value of the status of the asp page which is returned by the user. This Property is also used to change the status of the asp page. Syntax: response.Status=statusdescription Parameter Values: This property accepts a single value as mentioned above and described below: statusdescription: It represents a
1 min read
Semantic-UI Icon Set Status
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. In this article, we are going to learn about Icon Set Status. It is equipped with pre-built semantic components that help create respon
2 min read
HTTP 201 status code
What is HTTP ? HTTP stands for Hyper Text Transfer Protocol. Using this protocols, the clients communicate with server and vice versa. This concept is the core of internet, since it was created in 1990. HTTP is basic yet powerful file transfer protocol. Features of HTTP: HTTP is connectionless: This means that HTTP needs a continuous connection wit
3 min read
10 Most Common HTTP Status Codes
You search for anything on Google, and by this, a request is being sent to the server, then the server responds. This response is done using HTTP (HyperText Transfer Protocol) by the server. There can be two cases - the server may respond with the information it has, or else it may show an error with a code. Whenever there's an error in the back en
5 min read
What is the Battery Status API in HTML5 ?
Introduction: The Battery Status API sometimes referred to as the Battery API provides information about the battery of the computer. It provides the remaining battery level and charging status of the battery. It also gives an estimate of the remaining time to completely charge the battery or discharge the battery if it is charging or discharging.
4 min read
What do you understand by the HTTP Status Codes ?
The HTTP or the HyperText Transfer Protocol is a protocol of the application layer. It helps in establishing communication between a web browser and a web server. When a client requests any information, the browser sends a response using numeric status codes. These status codes are in the form of 3-digit numbers ranging from 100 - 599. The client t
3 min read
Angular PrimeNG TreeTable Loading Status
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use TreeTable Column Resize in Angular PrimeNG. Angular PrimeNG TreeTable Loading Status enables a loader in the T
5 min read
What are HTTP Status Codes ?
HTTP Protocol is used everywhere from the server page to each service communication, deploying service to monitoring service. HTTP codes give an extension of HTTP protocol to debug network problems using curl, telnet able to check server availability, service responses HTTP status code is used for search engine optimization of how your pages get in
8 min read
React Suite Steps Error Status
React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Steps is a navigation bar that guides users through the steps of a task. Error Status in Steps is used to show the error. It creates a Red Cross against the step that caused the error. Syntax: <Steps current=
3 min read
React Suite Nav Option Status
React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Nav Provides a list of various forms of navigation menus, which can be landscape and portrait layouts. Nav Option Status helps to enable or disable any nav Item. Syntax: <Nav> <Nav.Item active>Active
2 min read