2011-12-05 27 views

risposta

17

Di solito non si crea filiali direttamente nel repository nuda, ma si spingono i rami da un repository di lavoro per la nuda

git push origin myBranch 

Aggiornamento: Vale la pena di citare

Come Paolo Pladijs menzionato nel commenti con

git push origin localBranchName:remoteBranchName 

si spingono (e creano, se non esiste) la filiale locale per il telecomando con un nome diverso ramo, che quello locale. E per completarlo con

git push origin :remoteBranchName 

si elimina un ramo remoto.

+1

Se si vuole dare il ramo altro nome quindi utilizzare: 'git push origin localBranchName: remoteBranchName' –

4

Per creare un nuovo ramo (a livello locale) chiamato branchname

git branch brachname 

Poi per la sincronizzazione con il repository remoto come github (se applicabile)

git push origin branchname 

e di utilizzarlo per lo sviluppo/fare il ramo ramo attivo

git checkout branchname 
+1

in un repository nudo questo si traduce in un errore: * fatale: non un nome oggetto valido: 'master'. * –

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

In quel repository nudo se si ha accesso diretto ad esso. Puoi fornire qualsiasi riferimento (un tag per esempio) o un commit nell'ultimo argomento.

Qui di seguito è uno script di test:

$ 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 
Problemi correlati