2011-09-12 7 views
117

TL; DR: Ho un ramo "tracciato" che non riesco a tirare.Mi hai chiesto di tirare senza dirmi quale ramo vuoi unire con

Così qui io sono in "bucket-4":

$ git branch -v 
    bucket-1  410f7b5 * gh-53 * gh-48 * "Share App" 
    bucket-2  7ed70a2 * upgrade to SOLR 3.3.0 
    bucket-3  400ffe4 * emergency fix prod issue 
* bucket-4  64c2414 Merge branch 'bucket-3' into bucket-4 
    master   8dc4854 [ahead 1] * gh-73 

mi piacerebbe tirare cambiamenti dal mio telecomando:

$ git pull 

You asked me to pull without telling me which branch you 
want to merge with, and 'branch.bucket-4.merge' in 
your configuration file does not tell me, either. Please 
specify which branch you want to use on the command line and 
try again (e.g. 'git pull <repository> <refspec>'). 
See git-pull(1) for details. 

If you often merge with the same branch, you may want to 
use something like the following in your configuration file: 

    [branch "bucket-4"] 
    remote = <nickname> 
    merge = <remote-ref> 

    [remote "<nickname>"] 
    url = <url> 
    fetch = <refspec> 

See git-config(1) for details. 

Hmm, strano, ho pensato che già aggiunto "bucket-4" come ramo di tracciamento. Vediamo:

$ git remote show origin 
* remote origin 
    Fetch URL: [email protected]:abcd/main.git 
    Push URL: [email protected]:abcd/main.git 
    HEAD branch (remote HEAD is ambiguous, may be one of the following): 
    bucket-3 
    master 
    Remote branches: 
    bucket-1  tracked 
    bucket-2  tracked 
    bucket-3  tracked 
    bucket-4  tracked 
    master   tracked 
    Local branches configured for 'git pull': 
    bucket-1  merges with remote bucket-1 
    bucket-2  merges with remote bucket-2 
    bucket-3  merges with remote bucket-3 
    master   merges with remote master 
    Local refs configured for 'git push': 
    bucket-1  pushes to bucket-1  (up to date) 
    bucket-2  pushes to bucket-2  (up to date) 
    bucket-3  pushes to bucket-3  (up to date) 
    bucket-4  pushes to bucket-4  (local out of date) 
    master   pushes to master   (fast-forwardable) 

Infatti, secchio-4 è contrassegnato come "monitorati", eppure in qualche modo è configurato per spingere, ma non tirare.

Guardando il mio file .git/config, vedo che ho voci "remote" e "unire" per la maggior parte delle mie filiali, ma non per bucket-4. Come viene considerato "tracciato" senza questo?

[remote "origin"] 
    url = [email protected]:abcd/main.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 
[branch "master"] 
    remote = origin 
    merge = refs/heads/master 
[branch "rel-2011-07-07"] 
    remote = origin 
    merge = refs/heads/rel-2011-07-07 
[branch "bucket-1"] 
    remote = origin 
    merge = refs/heads/bucket-1 
[branch "bucket-2"] 
    remote = origin 
    merge = refs/heads/bucket-2 
[branch] 
    autosetupmerge = true 
[branch "bucket-3"] 
    remote = origin 
    merge = refs/heads/bucket-3 

vedo che la probabile soluzione è quella di aggiungere voci per remote/merge secchio-4 nel mio file di configurazione. Ma come viene considerato "tracciato" senza questo? bucket-4 è stato creato localmente, quindi inviato al server da questo repository, quindi sospetto che in qualche modo non ho impostato correttamente il tracciamento per questo ramo.

C'è qualche configurazione che posso aggiungere per far sì che tutte le filiali locali seguano correttamente i loro telecomandi in futuro?

+2

Questa domanda mi ha indirizzato nella giusta direzione, ho solo dovuto aggiungere una voce nel mio file .git/config per il ramo che stavo cercando di tirare, quindi ha funzionato bene. –

+0

Anche io, e il modo per farlo è come Mark Longair descritto di seguito con git branch --set-upstream bucket-4 origine/bucket-4 –

risposta

183

Dice bucket-4 pushes to bucket-4 solo perché il valore predefinito quando si preme un ramo è di inserirlo in uno con un nome corrispondente sul telecomando. (Si noti che questo è ancora difetto, anche se il ramo locale sta tracciando un ramo remoto-tracking ed il ramo remoto-tracking corrisponde a un ramo con un nome differente nel repository remoto.)

Il modo più semplice per impostare l'associazione tra il tuo bucket-4 e bucket-4 in origin è quello di assicurarsi che la prossima volta che si preme, si fa:

git push -u origin bucket-4 

in alternativa, si può fare:

git branch --set-upstream bucket-4 origin/bucket-4 

Per rispondere a un paio di domande direttamente:

Come viene nemmeno preso in considerazione "monitorati" senza questo?

In questo caso non è - non è il tracciamento della filiale remota-tracking in alcun senso se non c'è branch.bucket-4.merge o branch.bucket-4.remote nella vostra configurazione git. L'output di git remote show origin mostra semplicemente dove verrà inserito il ramo per impostazione predefinita.

C'è qualche configurazione che posso aggiungere per far sì che tutte le filiali locali seguano correttamente i telecomandi in futuro?

Non credo che ci sia.Quando hai creato bucket-4 localmente, come presumo sia successo, il ramo di localizzazione remota non esisteva, quindi non può essere impostato in quel punto - sarebbe un comportamento predefinito molto confuso. Devi solo ricordare di aggiungere -u al tuo primo git push di quel ramo al suo repository upstream.

Spero che sia di qualche aiuto.

+7

Il parametro "-u" ha fatto il trucco. – neoneye

+7

'git branch --set-upstream 'ha funzionato perfettamente per me prima di eseguire il pull – ohaal

+0

ramo git --set-upstream bucket-4 origine/bucket-4 ha funzionato per me :-) – Aliza

3

git branch --set-upstream <branch> origin/<branch> è stato dichiarato obsoleto almeno dal 1.8.2.3 (la mia versione).

Utilizzare invece git branch --set-upstream-to=origin/<branch> <branch>.

+2

Intendevi che questo fosse un commento su [la risposta di Mark] (http://stackoverflow.com/a/7388440/456814)? Inoltre, è stato deprecato in [Git versione 1.8.0] (https://github.com/git/git/blob/v2.0.4/Documentation/RelNotes/1.8.0.txt#L42-L47). –

Problemi correlati