Cosa restituisce git remote -v show
quando si tratta di origine?
Se l'origine punta a github, lo stato deve essere aggiornato e non in anticipo rispetto a qualsiasi repository remoto. Almeno, con il Git1.6.5 che sto usando per un test rapido.
In ogni caso, per evitare questo, definire in modo esplicito il repo remoto del ramo principale:
$ git config branch.master.remote yourGitHubRepo.git
poi un git pull origin master
, seguito da un git status
dovrebbe restituire uno stato pulito (non avanti).
Perché? poiché il master get get get (incluso nel generatore di origine git pull) non aggiornerebbe solo FETCH_HEAD
(come Charles Bailey spiega come his answer), ma sarebbe anche aggiornare il "ramo master remoto" nel repository Git locale.
In tal caso, il tuo master locale non sembrerebbe più "avanti" del master remoto.
Posso testare questo, con un git1.6.5:
prima cosa creare un workrepo:
PS D:\git\tests> cd pullahead
PS D:\git\tests\pullahead> git init workrepo
Initialized empty Git repository in D:/git/tests/pullahead/workrepo/.git/
PS D:\git\tests\pullahead> cd workrepo
PS D:\git\tests\pullahead\workrepo> echo firstContent > afile.txt
PS D:\git\tests\pullahead\workrepo> git add -A
PS D:\git\tests\pullahead\workrepo> git commit -m "first commit"
ho simulare un repo GitHub con la creazione di un pronti contro termine nudo (uno che può ricevere spinta da qualsiasi luogo)
PS D:\git\tests\pullahead\workrepo> cd ..
PS D:\git\tests\pullahead> git clone --bare workrepo github
aggiungo un modif a il mio repo di lavoro, che mi spingono a github pronti contro termine (aggiunto come un telecomando)
PS D:\git\tests\pullahead> cd workrepo
PS D:\git\tests\pullahead\workrepo> echo aModif >> afile.txt
PS D:\git\tests\pullahead\workrepo> git ci -a -m "a modif to send to github"
PS D:\git\tests\pullahead\workrepo> git remote add github d:/git/tests/pullahead/github
PS D:\git\tests\pullahead\workrepo> git push github
creo un repo casa, o clonato f GitHub, in cui faccio un paio di modifiche, spinto al GitHub:
PS D:\git\tests\pullahead\workrepo> cd ..
PS D:\git\tests\pullahead> git clone github homerepo
PS D:\git\tests\pullahead> cd homerepo
PS D:\git\tests\pullahead\homerepo> type afile.txt
firstContent
aModif
PS D:\git\tests\pullahead\homerepo> echo aHomeModif1 >> afile.txt
PS D:\git\tests\pullahead\homerepo> git ci -a -m "a first home modif"
PS D:\git\tests\pullahead\homerepo> echo aHomeModif2 >> afile.txt
PS D:\git\tests\pullahead\homerepo> git ci -a -m "a second home modif"
PS D:\git\tests\pullahead\homerepo> git push github
Ho poi clonare workrepo per un primo esperimento
PS D:\git\tests\pullahead\workrepo4> cd ..
PS D:\git\tests\pullahead> git clone workrepo workrepo2
Initialized empty Git repository in D:/git/tests/pullahead/workrepo2/.git/
PS D:\git\tests\pullahead> cd workrepo2
PS D:\git\tests\pullahead\workrepo2> git remote add github d:/git/tests/pullahead/github
PS D:\git\tests\pullahead\workrepo2> git pull github master
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From d:/git/tests/pullahead/github
* branch master -> FETCH_HEAD
Updating c2763f2..75ad279
Fast forward
afile.txt | Bin 46 -> 98 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
In questo repo, git status fa menzione padrone geing anticipo 'origin
':
PS D:\git\tests\pullahead\workrepo5> git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)
Ma questa è solo origin
non è GitHub:
PS D:\git\tests\pullahead\workrepo2> git remote -v show
github d:/git/tests/pullahead/github (fetch)
github d:/git/tests/pullahead/github (push)
origin D:/git/tests/pullahead/workrepo (fetch)
origin D:/git/tests/pullahead/workrepo (push)
Ma se ripeto la sequenza in un repo, che ha un'origine a github (o nessuna origine a tutti, solo un 'github' a distanza definita), lo stato è pulito:
PS D:\git\tests\pullahead\workrepo2> cd ..
PS D:\git\tests\pullahead> git clone workrepo workrepo4
PS D:\git\tests\pullahead> cd workrepo4
PS D:\git\tests\pullahead\workrepo4> git remote rm origin
PS D:\git\tests\pullahead\workrepo4> git remote add github d:/git/tests/pullahead/github
PS D:\git\tests\pullahead\workrepo4> git pull github master
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From d:/git/tests/pullahead/github
* branch master -> FETCH_HEAD
Updating c2763f2..75ad279
Fast forward
afile.txt | Bin 46 -> 98 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
PS D:\git\tests\pullahead\workrepo4> git status
# On branch master
nothing to commit (working directory clean)
Se dovessi solo origin
che punta su github
, status
sarebbe pulito per git1.6.5.
Potrebbe essere con un avviso "avanti" per il git precedente, ma in ogni caso, una definizione esplicita di git config branch.master.remote yourGitHubRepo.git
dovrebbe essere in grado di occuparsene, anche con le versioni precedenti di Git.
Ho notato anche questo; anche un 'git push' sembra risolverlo (riportando" tutto aggiornato "). –
'git config --get-regexp br. *' Può dirti se la tua configurazione ha un ramo locale sta monitorando un altro ramo – VonC
Puoi digitare 'git config branch.master.remote yourGitHubRepo.git' nel tuo workRepo e controllare (a il prossimo 'git pull origin') se lo stato rimane con un avviso 'avanti'? – VonC