2015-01-01 27 views
5

Nel mio repository, ho un ramo master e un ramo new.! [rifiutato] master -> master (non veloce) in un nuovo ramo aggiornato

Ho lavorato su new per un po ', facendo commit e spingo mentre vado. Ho deciso ora di diramare lo new e chiamarlo newest. Così ho fatto

git checkout -b "newest" 

e il ramo è stato creato con successo. Ho aggiunto un file e ho iniziato a lavorarci. Ho effettuato i miei cambiamenti un paio di volte.

ma quando provo a spingere questo nuovo ramo e le mie modifiche ad esso per origin, ottengo questo errore:

C:\wamp\www\myproj>git push origin 
To https://github.com/Imray/Proj.git 
! [rejected]  master -> master (non-fast-forward) 
! [rejected]  new -> new (non-fast-forward) 
error: failed to push some refs to 'https://github.com/Imray/Proj.git' 
hint: Updates were rejected because a pushed branch tip is behind its remote 
hint: counterpart. Check out this branch and integrate the remote changes 
hint: (e.g. 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

Così, come specificato nelle istruzioni, ho provato git pull, ma poi mi sono:

There is no tracking information for the current branch. 
Please specify which branch you want to merge with. 
See git-pull(1) for details 

    git pull <remote> <branch> 

If you wish to set tracking information for this branch you can do so with: 

    git branch --set-upstream-to=origin/<branch> newest 

mi sono bloccato.

Come si invia il nuovo ramo e le modifiche a github?

risposta

2

Controlla il tuo git config push.default. Potrebbe essere su "matching", poiché tenta di trasferire tutti i rami esistenti.
Quello era il default before Git 2.0+.

Si consiglia di impostarlo su "simple", al fine di spingere solo il ramo corrente.

Detto questo, per spingere un ramo, è necessario (per la prima spinta) per impostare uno upstream branch.

Per un ramo mai spinto prima:

git push -u origin newest 

Per un ramo che non esiste sul upstream repo:

git branch --set-upstream-to=origin/master master 
git branch --set-upstream-to=origin/new new 

Poi un'opera git checkout master ; git pull would.