github come flusso di lavoro su server privato su ssh
-
02-10-2019 - |
Domanda
Ho un server (disponibile tramite SSH) su Internet che io e il mio amico utilizziamo per lavorare insieme a progetti. Abbiamo iniziato a utilizzare Git per il controllo della fonte. La nostra configurazione attualmente è la seguente:
- Amico creato repository su
server
insieme agit --bare init
di nomeproject.friend.git
- Ho clonato
project.friend.git
Suserver
aproject.jesse.git
- Ho poi clonato
project.jesse.git
Suserver
Alla mia macchina locale usandogit clone jesse@server:/git_repos/project.jesse.git
- Lavoro sulla mia macchina locale e mi impegno nella macchina locale. Quando voglio spingere le mie modifiche al
project.jesse.git
Suserver
Io usogit push origin master
. Il mio amico sta lavorandoproject.friend.git
. Quando voglio ottenere i suoi cambiamenti, facciopull jesse@server:/git_repos/project.friend.git
.
Tutto sembra funzionare bene, tuttavia, ora sto ricevendo il seguente errore quando lo faccio git push origin master
:
localpc:project.jesse jesse$ git push origin master
Counting objects: 100, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (76/76), 15.98 KiB, done.
Total 76 (delta 50), reused 0 (delta 0)
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 jesse@server:/git_repos/project.jesse.git
c455cb7..e9ec677 master -> master
Questo avvertimento è qualcosa di cui devo preoccuparmi? Come ho detto, tutto sembra funzionare. Il mio amico è in grado di estrarre i miei cambiamenti dal mio ramo. Ho il clone sul server in modo che possa accedervi poiché non ha accesso alla mia macchina locale. C'è qualcosa che potrebbe essere fatto meglio?
Grazie!
Soluzione
Dovresti impostare un spoglio repository sul server. Un repository nudo contiene solo le informazioni sulla cronologia della versione che di solito sono in .git
Directory nella radice del repository. Puoi clonare da esso o spingerlo come con qualsiasi altro repository.
I repository nudi sono creati con
git init --bare
Se hai già qualche cronologia della versione, fai un clone nudo
git clone --bare git://some/where
Per quanto riguarda il tuo avvertimento, vedi questa domanda.