codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
📦

Git & GitHub

4 / 63 topics
1Installing Git2Configuring Git3Initializing a Repository4Using git status5Using git add6Using git commit7Using git log8Using git diff
Tutorials/Git & GitHub/Using git status
📦Git & GitHub

Using git status

Updated 2026-04-20
3 min read

Introduction

In this tutorial, we will explore how to use the git status command effectively. This command is fundamental for understanding the current state of your working directory and staging area. By mastering git status, you can efficiently manage changes, resolve conflicts, and ensure that your project's history remains accurate.

Understanding Git Status

The git status command provides a snapshot of your working directory and staging area. It shows which files have been modified, staged, or are untracked. This information is crucial for making informed decisions about committing changes to your repository.

Basic Usage

To use the git status command, navigate to your Git repository's root directory in the terminal and run:

git status

This command will output a detailed report of the current state of your repository. Here’s what you might see:

On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   README.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        new_feature/

no changes added to commit (use "git add" and/or "git commit -a")

Key Components of Git Status Output

  1. Branch Information: Shows the current branch you are on.
  2. Changes Not Staged for Commit: Lists files that have been modified but not yet staged.
  3. Untracked Files: Lists new files that Git has not yet tracked.
  4. Staged Changes: Lists files that have been added to the staging area and are ready to be committed.

Best Practices

1. Regularly Check Status

It's a good practice to run git status frequently, especially before making commits. This helps you understand what changes will be included in your next commit and ensures you don't accidentally include unwanted files.

2. Use Staging Area Wisely

The staging area allows you to selectively choose which changes to include in a commit. By using git add, you can stage specific files or directories, while leaving others unmodified. This gives you fine-grained control over your commits.

3. Resolve Conflicts Early

If you encounter conflicts during merges or pulls, git status will highlight them. Addressing conflicts early helps maintain a clean and error-free project history.

Advanced Usage

1. Short Status Output

For a more concise view of the repository's state, use the --short option:

git status --short

This command provides a compact output that includes only the file statuses:

 M README.md
?? new_feature/
  • M indicates a modified file.
  • ? indicates an untracked file.

2. Show Untracked Files

To see only untracked files, use the --untracked-files=no option:

git status --untracked-files=no

This can be useful when you want to focus on changes that have already been staged or modified.

3. Show Branch Information

If you are working with multiple branches and need a quick reminder of which branch you are on, use the --branch option:

git status --branch

This command will display only the current branch information without listing file statuses.

Real-World Example

Let's walk through a real-world scenario to illustrate how git status can be used effectively.

Scenario: Updating README and Adding New Feature

  1. Modify README.md: Open README.md in your text editor and make some changes.

  2. Add New Feature Directory: Create a new directory called new_feature with some files inside it.

  3. Check Status: Run git status to see the current state of your repository:

    git status
    

    Output:

    On branch main
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   README.md
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            new_feature/
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
  4. Stage Changes: Stage the modified README.md file:

    git add README.md
    
  5. Check Status Again: Run git status again to see the updated state:

    git status
    

    Output:

    On branch main
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            new file:   new_feature/file1.txt
            modified:   README.md
    
    Untracked files not shown (use -u option to show)
    
  6. Commit Changes: Commit the staged changes:

    git commit -m "Update README and add new feature"
    
  7. Final Check: Run git status one last time to ensure everything is clean:

    git status
    

    Output:

    On branch main
    nothing to commit, working tree clean
    

Conclusion

The git status command is an essential tool for any Git user. By understanding how to use it effectively, you can maintain a clear and organized project history, avoid common mistakes, and work more efficiently with your team. Regularly checking the status of your repository ensures that you are always aware of changes and can make informed decisions about your workflow.

In the next section of our "Git & GitHub" course, we will explore how to resolve merge conflicts using git status as a guide. Stay tuned for more advanced Git techniques!


PreviousInitializing a RepositoryNext Using git add

Recommended Gear

Initializing a RepositoryUsing git add