Spesso ho bisogno di sviluppare cose sulla strada, senza connessione internet/rete. Sono solo un singolo sviluppatore, quindi fino ad ora avevo semplicemente un repository SVN sulla mia macchina e ho fatto un checkout sul mio portatile quando sono andato via. Problema: questo non mi dà il controllo del codice sorgente sulla strada.setup git per un singolo sviluppatore?
Così ho provato a cambiare git, che sembra fare quello che voglio, ma non sono sicuro di aver capito correttamente come dovrebbe essere usato nel mio setup.
In sostanza:
- Creato un repository su \ myserver \ share \ progetto utilizzando
git init
- clonati quel repository alla macchina 1 utilizzando
git clone
- Cloned quel repository di macchina 2 utilizzando
git clone
- Ha lavorato sulla macchina 2, utilizzando
git commit
per confermare eventuali modifiche al mio repository locale - F inalmente utilizzato
git push
per spingere tutte le modifiche al \ myserver \ share \ prohect - Usato
git pull
sulla macchina 1 per ottenere nuovi cambiamenti da \ myserver share \ progetto \
che funziona, ma il comando git push
me un dà avviso che dice che la spinta del ramo fuori controllo non è supportata in quanto potrebbe confondere l'indice. Ora, sono confuso, perché il messaggio è stato anche scritto in tono serio, il che significa che dovrei onorarlo (e in effetti, Gitk mostra che ora ho due rami: master e remoti/origine/master), ma io non capisco ancora completamente la terminologia.
Quali sarebbero i passaggi corretti nella mia situazione?
- io sempre e solo lavorare sulla macchina 1 OR macchina 2, non sia
- intendo usare ramificazione come un modo per avere un ramo separato per bugfixes/test (come nel solito modo), ma non come un modo per avere più sviluppatori
- Principalmente voglio usarlo come alternativa a rsync my SVN.
Modifica: ci sono due stranezze. Il primo è se cambio semplicemente un file, dice "Modificato ma non aggiornato". che è strano:
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: myproject/Readme.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Il secondo messaggio è quello che credo sia il colpevole, l'output di git push:
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning: 'nothing' : Do not push anything
warning: 'matching' : Push all matching branches (default)
warning: 'tracking' : Push the current branch to whatever it is tracking
warning: 'current' : Push the current branch
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 333 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning:
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning:
warning: To squelch this message, you can set it to 'warn'.
warning:
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To file:///\\myserver\share\project
129649b..1f4b957 master -> master
Così mi dice che "spingendo nel ramo corrente" è non raccomandato, ma non ho davvero capito quale sia il modo corretto di farlo.
Sto usando git per risolvere lo stesso problema. Non ho lo stesso problema, ma l'ho affrontato in modo un po 'diverso. Sto usando un server Linux a casa come repository centrale, quindi tutte le mie posizioni di sviluppo sono cloni della centrale. Puoi copiare il messaggio di errore esatto? Potrebbe aiutarmi a rispondere meglio alla tua domanda. –
Questo ha aiutato. Hai un paio di buone risposte da altre persone, che sto votando. –