git add

git

इस्तेमाल

git add [-A|-u|-p] <pathspec>...

फ़ाइल को उसी क्षण की हालत में staging पर रखता है; add के बाद फिर बदलाव किया तो वह छूट जाता है और दोबारा add करना पड़ता है।

आम विकल्प

विकल्पअर्थ
-Astage every change in the whole tree, deletions included
-ustage changes to tracked files only, no new files
-pwalk the diff and choose hunk by hunk
-ndry run: list what would be staged
-fstage a file that .gitignore excludes
-Nrecord the path only, so the file shows up in diffs

उदाहरण

git add -A

stages everything, including files you deleted

git add -p src/app.ts

stages part of one file and leaves the rest

git add .

stages everything under the current directory

उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. git add क्या करता है?

फ़ाइल को उसी क्षण की हालत में staging पर रखता है; add के बाद फिर बदलाव किया तो वह छूट जाता है और दोबारा add करना पड़ता है।

Q. इसे कैसे लिखें?

git add [-A|-u|-p] <pathspec>... — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 6 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।

मिलती-जुलती कमांड

man पेज: man git-add