2011-12-05 16 views
17

में एक नंगे भंडार में शाखा कैसे बनाएं I वर्तमान में एक नंगे रेपो है जो मेरी टीम के लिए केंद्रीय रेपो के रूप में कार्य करता है। नंगे रेपो में वर्तमान में केवल एक शाखा "मास्टर" है। मैं नंगे रेपो पर और शाखाएं कैसे बना सकता हूं?गिट

उत्तर

17

आमतौर पर आप नंगे भंडार में सीधे शाखाओं का निर्माण नहीं है, लेकिन आप के लिए नंगे

git push origin myBranch 

अद्यतन एक काम रिपोजिटरी से शाखाओं धक्का: वर्थ का उल्लेख

तरह पॉल Pladijs में उल्लेख किया

git push origin localBranchName:remoteBranchName 

आप अपनी स्थानीय शाखा को रिमोट में एक अलग शाखा नाम के साथ धक्का देते हैं (और बनाते हैं, यदि मौजूद नहीं है), तो आपका स्थानीय एक। और

git push origin :remoteBranchName 

के साथ इसे पूरा करने के लिए आप एक दूरस्थ शाखा हटाते हैं।

+1

आप शाखा एक और नाम तो का उपयोग देना चाहते हैं: 'Git धक्का मूल localBranchName: remoteBranchName' –

4

एक नई शाखा (स्थानीय) कहा जाता BRANCHNAME

git branch brachname 

तो GitHub की तरह दूरदराज के भंडार के साथ सिंक करने के लिए (यदि लागू हो)

git push origin branchname 

और विकास के लिए उपयोग करने के लिए बनाने के लिए/बनाने शाखा सक्रिय शाखा

git checkout branchname 
+1

एक नंगे भंडार में यह एक त्रुटि में परिणाम है:

नीचे एक परीक्षण स्क्रिप्ट है * घातक: मान्य वस्तु नाम नहीं: 'मास्टर'। * –

5
git update-ref refs/heads/new_branch refs/heads/master 

उस नंगे भंडार में यदि आपके पास सीधे पहुंच है। आप किसी भी संदर्भ (उदाहरण के लिए एक टैग) या अंतिम तर्क में एक प्रतिबद्धता की आपूर्ति कर सकते हैं।

$ mkdir non-bare-orig 

$ cd non-bare-orig/ 

$ git init 
Initialized empty Git repository in D:/Temp/bare-branch/non-bare-orig/.git/ 

$ touch file1 

$ git add --all && git commit -m"Initial commit" 
[master (root-commit) 9c33a5a] Initial commit 
1 file changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 file1 

$ touch file2 

$ git add --all && git commit -m"Second commit" 
[master 1f5673a] Second commit 
1 file changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 file2 

$ git tag some_tag 

$ touch file3 

$ git add --all && git commit -m"Third commit" 
[master 5bed6e7] Third commit 
1 file changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 file3 

$ cd ../ 

$ git clone --bare non-bare-orig bare-clone 
Cloning into bare repository 'bare-clone'... 
done. 

$ cd bare-clone/ 

$ git update-ref refs/heads/branch1 refs/heads/master 

$ git update-ref refs/heads/branch2 some_tag 

$ git update-ref refs/heads/branch3 9c33a5a 

$ git branch -vv 
    branch1 5bed6e7 Third commit 
    branch2 1f5673a Second commit 
    branch3 9c33a5a Initial commit 
* master 5bed6e7 Third commit