0
0
Gitdevops~3 mins

git status to see current state - Commands & Configuration

Choose your learning style9 modes available
Introduction
When working on code, you often need to know what changes you have made and what files are ready to be saved. The git status command shows you the current state of your project, including changes and files not yet saved.
When you want to check which files have been changed before saving your work.
When you want to see if there are new files that git is not tracking yet.
Before committing changes to make sure you know exactly what will be saved.
After pulling updates from others to see if your files are different.
When you want to confirm if your working directory is clean or has pending changes.
Commands
This command shows the current state of your working directory and staging area. It tells you which files are modified, staged for commit, or untracked.
Terminal
git status
Expected OutputExpected
On branch main Your branch is up to date with 'origin/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: example.txt Untracked files: (use "git add <file>..." to include in what will be committed) newfile.txt no changes added to commit (use "git add" and/or "git commit -a")
Key Concept

If you remember nothing else from this pattern, remember: git status tells you exactly what files have changed and what is ready to be saved.

Common Mistakes
Running git status expecting it to save or commit changes.
git status only shows the state; it does not save or commit anything.
Use git add to stage changes and git commit to save them.
Ignoring untracked files shown by git status.
Untracked files are not saved in git until you add them, so they can be lost or forgotten.
Use git add to start tracking new files you want to save.
Summary
git status shows which files are changed, staged, or untracked.
It helps you understand what will be included in your next commit.
Use it often to keep track of your work before saving changes.