git clean

git

इस्तेमाल

git clean -n | git clean -fd

untracked फ़ाइलें मिटा देता है, जिनकी git के पास कभी प्रति नहीं थी, सो कुछ वापस नहीं आता; -fdx स्थानीय .env जैसी ignored फ़ाइलें भी हटाता है, पहले -n चलाएँ।

आम विकल्प

विकल्पअर्थ
-ndry run: list what would be deleted
-factually delete; without it git refuses
-dalso remove untracked directories
-xalso remove ignored files such as .env and node_modules
-Xremove only ignored files
-idecide interactively

उदाहरण

git clean -nd

lists the untracked files and folders that -fd would delete

git clean -fd

deletes them; git never had a copy, so there is no undo

git clean -fdx

also 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