2012-08-03 16 views

risposta

137

Se vi ricordate che si diramano è stato estratto prima (ad esempio master) si potrebbe semplicemente

git checkout master 

uscire di indipendente HEAD stato.

In generale: git checkout <branchname> ti farà uscire da quello.

Se non si ricorda il cognome ramo, provare

git checkout - 

Questo cerca anche di controllare il vostro ultimo ramo verificato.

13

Utilizzare git reflog per trovare gli hash dei commit precedentemente estratti.

Un comando scorciatoia per arrivare al tuo ultimo ramo controllato (non so se questo lavoro correttamente con HEAD distaccato e intermedio commette però) è git checkout -

0

ho avuto questo caso limite, in cui ho verificato una versione precedente del codice in cui la mia struttura di directory del file era diversa:

git checkout 1.87.1          
warning: unable to unlink web/sites/default/default.settings.php: Permission denied 
... other warnings ... 
Note: checking out '1.87.1'. 

You are in 'detached HEAD' state. You can look around, make experimental 
changes and commit them, and you can discard any commits you make in this 
state without impacting any branches by performing another checkout. 

If you want to create a new branch to retain commits you create, you may 
do so (now or later) by using -b with the checkout command again. 
Example: 

    git checkout -b <new-branch-name> 

HEAD is now at 50a7153d7... Merge branch 'hotfix/1.87.1' 

In un caso come questo, potrebbe essere necessario utilizzare --force (quando sai che tornare al ramo originale e scartare i cambiamenti è una cosa sicura da fare).

git checkout master non ha funzionato:

$ git checkout master 
error: The following untracked working tree files would be overwritten by checkout: 
web/sites/default/default.settings.php 
... other files ... 

git checkout master --force (o git checkout master -f) ha lavorato:

git checkout master -f 
Previous HEAD position was 50a7153d7... Merge branch 'hotfix/1.87.1' 
Switched to branch 'master' 
Your branch is up-to-date with 'origin/master'. 
Problemi correlati