2011-12-05 31 views

Respuesta

17

Por lo general, no se crea ramas directamente en el repositorio desnuda, pero se presiona ramas de un repositorio de trabajo al desnudo

git push origin myBranch 

Actualización: Vale la pena mencionar

Al igual que Pablo menciona en el Pladijs comentarios con

git push origin localBranchName:remoteBranchName 

te empuje (y crear, si no existe) con su sucursal local para el control remoto con un nombre de rama diferente, que su ser local. Y para que sea completa con

git push origin :remoteBranchName 

elimina una rama remota.

+1

Si desea dar a la rama utilizar otro nombre a continuación: 'git push origin localBranchName: remoteBranchName' –

4

Para crear una nueva rama (localmente) llamada BRANCHNAME

git branch brachname 

A continuación, sincronizarlo con el repositorio remoto como github (si es aplicable)

git push origin branchname 

y utilizarla para el desarrollo/hacer la rama de la rama activa

git checkout branchname 
+1

En un repositorio desnudo esto se traduce en un error: * fatal: no es un nombre de objeto válido: 'maestro'. * –

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

En ese repositorio vacío si tiene acceso directo a él. Puede proporcionar cualquier referencia (una etiqueta, por ejemplo) o una confirmación en el último argumento.

A continuación se muestra un script de prueba:

$ 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 
Cuestiones relacionadas