git clean
git
इस्तेमाल
git clean -n | git clean -fduntracked फ़ाइलें मिटा देता है, जिनकी git के पास कभी प्रति नहीं थी, सो कुछ वापस नहीं आता; -fdx स्थानीय .env जैसी ignored फ़ाइलें भी हटाता है, पहले -n चलाएँ।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| -n | dry run: list what would be deleted |
| -f | actually delete; without it git refuses |
| -d | also remove untracked directories |
| -x | also remove ignored files such as .env and node_modules |
| -X | remove only ignored files |
| -i | decide interactively |
उदाहरण
git clean -ndlists the untracked files and folders that -fd would delete
git clean -fddeletes them; git never had a copy, so there is no undo
git clean -fdxalso wipes ignored files, including local .env and build output
उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. git clean क्या करता है?
untracked फ़ाइलें मिटा देता है, जिनकी git के पास कभी प्रति नहीं थी, सो कुछ वापस नहीं आता; -fdx स्थानीय .env जैसी ignored फ़ाइलें भी हटाता है, पहले -n चलाएँ।
Q. इसे कैसे लिखें?
git clean -n | git clean -fd — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 6 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।
मिलती-जुलती कमांड
man पेज: man git-clean