git switch

git

इस्तेमाल

git switch [-c <new>] <branch>

git 2.23 का आदेश जो सिर्फ़ branch बदलता है; फ़ाइलों की सामग्री कभी नहीं लौटाता, वह काम restore का है।

आम विकल्प

विकल्पअर्थ
-c <new>create the branch and switch to it
-C <new>create it, or reset it here if it exists
-go back to the branch you were on before
--detach <commit>check out a commit without a branch
--track <remote>/<branch>follow a remote branch
-mcarry uncommitted changes across by merging them

उदाहरण

git switch main

moves to main; refuses if that would clobber your edits

git switch -c feature/api

creates the branch and moves there

git switch -

jumps back to the previous branch

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

कैसे पढ़ें

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

आम सवाल

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

git 2.23 का आदेश जो सिर्फ़ branch बदलता है; फ़ाइलों की सामग्री कभी नहीं लौटाता, वह काम restore का है।

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

git switch [-c <new>] <branch> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

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

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

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

man पेज: man git-switch