2012-08-02 24 views
14

corro:git checkout un altro ramo

git checkout mygithub/master 

ma per qualche ragione, in esecuzione 'git status' mostra "non sono attualmente su qualsiasi ramo". Esecuzione:

git checkout master 

e poi git status, dice che io sono ora in poi maestro ramo. Ora voglio passare a un altro ramo. L'esecuzione di git checkout anotherbranch funziona, ma git status dice che sono ancora nel master di ramo. Che cosa sto facendo di sbagliato?

+0

Does 'git checkout anotherbranch' produce un output? – poke

+0

Non mostra alcun output, nessun errore. – NoBugs

risposta

18

mygithub/master è una filiale remota. Per creare un ramo locale basato su tale ramo remoto, è necessario utilizzare git checkout -b mymaster mygithub/master. Git cerca di renderlo più facile per te: se scrivi git checkout branchname, e branchname esiste solo in un remoto, ma non in locale, Git imposterà automaticamente un ramo locale con <remote>/branchname come genitore.

+0

Quindi perché git checkout branchname non passa mai a questo? Il ramo esiste su github, voglio solo unire le modifiche principali ad esso. – NoBugs

+0

@NoBugs: 'git checkout -b remotemaster mygithub/master' dovrebbe creare un nuovo ramo off' mygithub/master' e passare ad esso. – knittl

+0

'git checkout -b otherbranch mygithub/otherbranch' funziona, ma' git unire mygithub/master' vuole 'avanzare velocemente' ed elimina i file dal non master, che voglio conservare. – NoBugs

9

Se si desidera passare a un altro ramo quindi eseguire il seguente comando:

git checkout branch name 

Se si desidera eliminare un ramo quindi eseguire il seguente comando:

git branch -D branch name 

Se si desidera creare un nuovo ramo quindi eseguire questo comando:

git checkout -b branch 
Problemi correlati