git diff
git
इस्तेमाल
git diff [--staged] [<commit>] [-- <path>]सिर्फ़ वे बदलाव दिखाता है जो अभी staged नहीं हैं; इसीलिए git add के तुरंत बाद खाली लगता है — तब --staged लगाएँ।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| --staged | compare the staged snapshot with HEAD (same as --cached) |
| --stat | summary of files and line counts instead of the patch |
| -w | ignore whitespace changes |
| --name-only | list changed paths only |
| <a>...<b> | changes on b since it forked from a |
| -- <path> | restrict to a path; the -- keeps it from being read as a branch |
उदाहरण
git diffshows only what is NOT staged yet
git diff --stagedshows what git commit would record
git diff main...featurethe work feature added since it left main
उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. git diff क्या करता है?
सिर्फ़ वे बदलाव दिखाता है जो अभी staged नहीं हैं; इसीलिए git add के तुरंत बाद खाली लगता है — तब --staged लगाएँ।
Q. इसे कैसे लिखें?
git diff [--staged] [<commit>] [-- <path>] — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 6 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।
मिलती-जुलती कमांड
man पेज: man git-diff