git worktree

git

इस्तेमाल

git worktree add <path> [<branch>]

उसी repository से दूसरा working फ़ोल्डर निकालता है, जिससे दोबारा clone किए बिना दो branch साथ चल सकें; एक ही branch दो जगह checkout नहीं हो सकती, और फ़ोल्डर हाथ से मिटाने पर prune तक प्रविष्टि बची रहती है।

आम विकल्प

विकल्पअर्थ
add <path> <branch>check that branch out into another folder
add -b <new> <path>create a branch and check it out there
listshow every working tree of this repository
remove <path>delete a working tree cleanly
pruneforget trees whose folder you deleted by hand
--detachcheck out a commit without a branch

उदाहरण

git worktree add ../hotfix hotfix/login

a second folder on another branch, sharing one .git

git worktree add -b release ../rel main

creates release from main in ../rel

git worktree remove ../hotfix

removes the folder and its bookkeeping entry

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

कैसे पढ़ें

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

आम सवाल

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

उसी repository से दूसरा working फ़ोल्डर निकालता है, जिससे दोबारा clone किए बिना दो branch साथ चल सकें; एक ही branch दो जगह checkout नहीं हो सकती, और फ़ोल्डर हाथ से मिटाने पर prune तक प्रविष्टि बची रहती है।

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

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

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

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

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

man पेज: man git-worktree