← Back to Git Course | Chapter 2: Basic Commands | Lesson 5 of 18

Git status Command

git status एक teacher के 'अभी situation क्या है?' पूछने जैसा है। यह आपको बताता है कि कौन सी files बदलीं, कौन सी save होने के लिए ready हैं, और किसके बारे में Git को अभी पता नहीं।
Syntax
bash
git status
git status -s

git status क्या है?

git status Git का core diagnostic command है -- इसे तब चलाएँ जब आपको sure न हो कि आपका project किस state में है, और यह हर उस file को list करेगा जो last commit के बाद untracked, staged, या modified है, सब एक readable summary में।

उदाहरण: What is git status?

bash
git status

Untracked Status पढ़ना

Project folder के अंदर आपने अभी जो files बनाई हैं वे Untracked की तरह दिखती हैं -- Git ने notice किया है कि वे exist करती हैं लेकिन deliberately उनके contents को ignore कर रहा है जब तक आप explicitly उन्हें git add न करें, ताकि accidental files कभी history में न घुसें।

उदाहरण: Reading Untracked Status

bash
echo "new content" > newfile.txt
git status

Staged Status पढ़ना

'Changes to be committed' के तहत listed files staging area में बैठी हैं, यानी अगली बार जब आप git commit चलाएँ उनकी current state exactly as-is capture हो जाएगी -- commit करने से पहले confirm करने के लिए यह check करने वाला section है कि आप वही save कर रहे हैं जो आप चाहते थे।

उदाहरण: Reading Staged Status

bash
git add newfile.txt
git status

Modified Status पढ़ना

'Changes not staged for commit' के तहत files वे हैं जिन्हें Git पहले से track करता है और जिन्हें आपने बाद में modify किया है -- staged version और working-directory version अब अलग हैं, और staged की गई चीज़ update करने के लिए आपको दोबारा git add चलाना होगा।

उदाहरण: Reading Modified Status

bash
echo "more text" >> tracked.txt
git status

Shorthand Status Check

कई बदली हुई files वाले एक बड़े project के लिए, पूरा git status output overwhelming हो सकता है -- git status -s (या --short) हर file को एक two-letter status code के साथ एक single line में compress करता है, इसे scan करना कहीं तेज़ बनाते हुए।

उदाहरण: Shorthand Status Check

bash
git status -s
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. git status को committed history दिखाते हुए पढ़ना, जबकि यह सिर्फ untracked, modified और staged files की current state दिखाता है।
  2. 'Changes to be committed' और 'Changes not staged for commit' दो lists notice न करना, ताकि एक modified file को staged मान लिया जाए जब यह नहीं है।
  3. Git द्वारा print किया गया hint text ignore करना, जैसे use "git restore --staged <file>", जो exactly बताता है कि एक step कैसे undo करें।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.