2016-04-22 12 views
10

In git, wenn Sie eine direkt begehen Kasse erhalten Sie eine dicke, fette Warnung ab:deaktivieren Warnung über freistehende HEAD

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

Es ist in Ordnung - ich beabsichtige, in frei stehenden HEAD Zustand. Allerdings verwende ich dies in einem Skript, und ich möchte diese Warnung nicht in den Ausgabeprotokollen, aber ich möchte die normale Ausgabe.

Meine "hässliche" Lösung besteht nun darin, denselben Befehl zweimal auszuführen, zuerst mit -q, um die Warnung auszublenden, und noch einmal, um die normale Ausgabe zu erhalten: HEAD is now at deadbeef... Message, da die Warnung nur einmal gedruckt wird.

Kann die Warnung deaktiviert werden, damit ich Workarounds vermeiden oder die Ausgabe analysieren kann?

Antwort

17

Sie haben die Konfiguration für diese Aufgabe:

die gewünschte Nachricht, indem Sie den Konfigurations Wert auf false setzen sich aus:

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

detachedHead

Tipps angezeigt, wenn Sie haben git-checkout (1) verwendet, um in den Zustand "HEAD abheben" zu wechseln, um Anweisungen zum Erstellen von al zu geben okal Zweig nach der Tat.


advice.*

Diese Variablen steuern verschiedene optionale Hilfemeldungen neue Benutzer unterstützen konzipiert. Alle Beratung * Variablen standardmäßig auf true, und Sie können Git sagen, dass Sie keine Hilfe brauchen durch diese falsche Einstellung.

Sie eine der folgenden Aktionen nach der Beratung einstellen:

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

Danke, genau das, was ich suchte. – Zitrax

+0

Kühl. froh zu helfen – CodeWizard

+20

Um diese Warnung vorübergehend zu deaktivieren (d. h. ohne die Konfiguration zu ändern), machen Sie etwas wie 'git-c advice.detachedHead = false checkout '. – mjs

10

schamlos Kopieren Kommentar MJS ist es als Antwort auf Post auf seinem eigenen:

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

die -c advice.detachedHead=false Parameter ermöglichen es Ihnen, um die Warnung zu unterdrücken, ohne die globale Konfiguration zu ändern. Dies gilt nur für den Befehl.

Verwandte Themen