2016-04-22 14 views
10

In git, se si verifica un commit direttamente si ottiene un avvertimento grande grasso a partire da:disabilitare gli avvisi di Head indipendente

"You are in 'detached HEAD' state. You can look around ..." 

Va bene - ho intenzione di essere in stato di testa staccata. Tuttavia sto usando questo in uno script e non voglio questo avviso nei registri di output, ma voglio l'output normale.

La mia soluzione "brutta" ora è eseguire lo stesso comando due volte, prima con -q per nascondere l'avviso e un'altra volta per ottenere l'output normale: HEAD is now at deadbeef... Message poiché l'avviso viene stampato una sola volta.

L'avviso può essere disattivato in modo da evitare i workaround o l'analisi dell'output?

risposta

17

avete la configurazione per questo compito:

Impostare il messaggio desiderato off impostando il valore di configurazione su false:

# turn the detached message off 
git config --global advice.detachedHead false 

detachedHead

Consigli visualizzata quando hai usato git-checkout (1) per passare allo stato HEAD di scollegamento, per istruire come creare al ramo ocale dopo il fatto.


advice.*

Queste variabili controllano vari messaggi di aiuto opzionale progettato per aiutare i nuovi utenti. Tutti i consigli * variabili di default a true, e si può dire Git che non hai bisogno di aiuto impostando queste false:.

È possibile impostare una delle seguenti dopo il consiglio:

git config --global advice.<...> 


pushUpdateRejected 
    Set this variable to false if you want to disable 
     pushNonFFCurrent, 
     pushNonFFMatching, 
     pushAlreadyExists, 
     pushFetchFirst, and 
     pushNeedsForce simultaneously. 

pushNonFFCurrent 
    Advice shown when git-push(1) fails due to a non-fast-forward update 
    to the current branch. 

pushNonFFMatching 
    Advice shown when you ran git-push(1) and pushed matching refs 
    explicitly (i.e. you used :, or specified a refspec that isn’t your 
    current branch) and it resulted in a non-fast-forward error. 

pushAlreadyExists 
    Shown when git-push(1) rejects an update that does not qualify 
    for fast-forwarding (e.g., a tag.) 

pushFetchFirst 
    Shown when git-push(1) rejects an update that tries to overwrite a 
    remote ref that points at an object we do not have. 

pushNeedsForce 
    Shown when git-push(1) rejects an update that tries to overwrite a 
    remote ref that points at an object that is not a commit-ish, or make 
    the remote ref point at an object that is not a commit-ish. 

statusHints 
    Show directions on how to proceed from the current state in the output 
    of git-status(1), in the template shown when writing commit messages in 
    git-commit(1), and in the help message shown by git-checkout(1) when 
    switching branch. 

statusUoption 
    Advise to consider using the -u option to git-status(1) when the command 
    takes more than 2 seconds to enumerate untracked files. 

commitBeforeMerge 
    Advice shown when git-merge(1) refuses to merge to avoid overwriting 
    local changes. 

resolveConflict 
    Advice shown by various commands when conflicts prevent the operation 
    from being performed. 

implicitIdentity 
    Advice on how to set your identity configuration when your information 
    is guessed from the system username and domain name. 

detachedHead 
    Advice shown when you used git-checkout(1) to move to the detach HEAD 
    state, to instruct how to create a local branch after the fact. 

amWorkDir 
    Advice that shows the location of the patch file when git-am(1) fails 
    to apply it. 

rmHints 
    In case of failure in the output of git-rm(1), show directions on 
    how to proceed from the current state. 
+0

Grazie, esattamente quello che ho cercato. – Zitrax

+0

Freddo. contento di aiutare – CodeWizard

+20

Per disabilitare temporaneamente questo avviso (ad esempio senza cambiare configurazione), fare qualcosa come 'git -c advice.detachedHead = false checkout '. – mjs

10

spudoratamente copiare commento di mjs di pubblicarlo come una risposta da solo:

git -c advice.detachedHead=false checkout <refspec> 

il parametro -c advice.detachedHead=false vi permetterà di eliminare l'avviso senza dover cambiare la configurazione globale. Si applicherà solo al comando.

Problemi correlati