aboutsummaryrefslogtreecommitdiff
path: root/introduzione_a_git.rest
blob: aa8a0fe63d708bdc1847d55372e069bb96951f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
Introduzione a GIT
==================

.. contents::
   :class: handout

Un nuovo progetto
-----------------

.. class:: handout

   Iniziamo un nuovo progetto che vogliamo salvare sotto git: non serve 
   preoccuparsi di avere un server, e neanche un nome pubblicabile 
   per il progetto, basta creare una directory (che potremo rinominare 
   in futuro), dire a git di crearci un repository e poi si può inizare 
   subito a lavorare.

::

   $ mkdir greeter
   $ cd greeter/
   $ git init
   Initialized empty Git repository in /home/[...]/greeter/.git/

Qualche file
------------

.. class:: handout

   Creiamo i nostri file, in questo caso un programma in python 
   che saluterà le persone.

::

   $ mkdir greeter
   $ touch greeter/__init__.py
   $ cat > greeter/greeter.py
   class Greeter:
       """ """
   $ cat > greeter.py
   #!/usr/bin/env python

   def main():
       pass

   if __name__ == '__main__': main()
   $ chmod 755 greeter.py


GIT
---

.. class:: handout

   Con ``git status`` possiamo vedere che git si è accorto dell'esistenza
   di alcuni file, ma sono *untracked*, ovvero non considerati 
   dal controllo delle revisioni.

::

   $ git status
   # On branch master
   #
   # Initial commit
   #
   # Untracked files:
   #   (use "git add <file>..." to include in what will be committed)
   #
   #       greeter.py
   #       greeter/
   nothing added to commit but untracked files present (use "git add" to track)


In staging
----------

.. class:: handout

   Aggiungiamo quel che abbiamo fatto alla *staging area*, ovvero 
   diciamo a git di prendere in considerazione quella versione 
   del file perché venga successivamente salvata.

::
   
   $ git add greeter.py greeter/
   $ git status
   # On branch master
   #
   # Initial commit
   #
   # Changes to be committed:
   #   (use "git rm --cached <file>..." to unstage)
   #
   #       new file:   greeter.py
   #       new file:   greeter/__init__.py
   #       new file:   greeter/greeter.py
   #

Altre mod
---------

.. class:: handout

   Facendo altre modifiche e riguardando ``git status`` ci possiamo 
   accorgere di come git non salvi automaticamente tutti i cambiamenti 
   presenti nei file di cui tiene traccia, ma solo quelli che gli
   vengono indicati esplicitamente da salvare.

::

   $ cat > greeter/__init__.py
   from .greeter import Greeter
   $ git status
   # On branch master
   #
   # Initial commit
   #
   # Changes to be committed:
   #   (use "git rm --cached <file>..." to unstage)
   #
   #       new file:   greeter.py
   #       new file:   greeter/__init__.py
   #       new file:   greeter/greeter.py
   #
   # Changes not staged for commit:
   #   (use "git add <file>..." to update what will be committed)
   #   (use "git checkout -- <file>..." to discard changes in working directory)
   #
   #       modified:   greeter/__init__.py
   #

Ultimi preparativi
------------------

.. class:: handout

   A questo punto possiamo aggiungere anche le ultime modifiche:

::
   
   $ git add greeter/__init__.py


.. class:: handout

   Se è la prima volta che usiamo git su questo computer salviamo qualche 
   informazione su di noi, nel mio caso:

::

   $ git config --global user.name "Elena ``of Valhalla'' Grandi"
   $ git config --global user.email valhalla@trueelena.org

Commit
------

.. class:: handout

   E finalmente possiamo creare il nostro primo commit, un insieme 
   di file in una loro determinata versione al quale vengono associati 
   alcuni metadati (autore, data, ...) e soprattutto un identificativo 
   che è un hash crittografico dei contenuti.

   Il comando ``git commit`` apre un editor con il quale scrivere 
   un commento da associare al commit. Di solito si scrive una descrizione 
   breve da una riga (una 60ina di caratteri), e poi eventualmente 
   altre informazioni più approfondite.

::

   Skeleton for the new project.
   # Please enter the commit message for your changes. Lines starting
   # with '#' will be ignored, and an empty message aborts the commit.
   # On branch master
   #
   # Initial commit
   #
   # Changes to be committed:
   #   (use "git rm --cached <file>..." to unstage)
   #
   #       new file:   greeter.py
   #       new file:   greeter/__init__.py
   #       new file:   greeter/greeter.py
   #

Commit (2)
----------

::
   
   ".git/COMMIT_EDITMSG" 14L, 377C written
   [master (root-commit) b54e94f] Skeleton for the new project.
    3 files changed, 9 insertions(+)
    create mode 100755 greeter.py
    create mode 100644 greeter/__init__.py
    create mode 100644 greeter/greeter.py


log
---

.. class:: handout

   Con il comando ``git log`` possiamo vedere l'identificativo 
   completo del commit appena fatto, e qualche metadato.

::

   $ git log
   commit b54e94fde972281ca31a56ef0d36204addd4906b
   Author: Elena ``of Valhalla'' Grandi <valhalla@trueelena.org>
   Date:   Thu Nov 15 19:05:42 2012 +0100

       Skeleton for the new project.

Show
----

.. class:: handout

   E con ``git show`` possiamo vedere i dettagli del commit, con 
   tutte le modifiche che sono state introdotte (sotto forma 
   di diff dalla versione precedente).

   Possiamo vedere come non serva scrivere tutto l'identificativo 
   del commit, ma bastino i primi caratteri sufficienti ad 
   identificarlo univocamente nel repository.

::

   $ git show b54e
   commit b54e94fde972281ca31a56ef0d36204addd4906b
   Author: Elena ``of Valhalla'' Grandi <valhalla@trueelena.org>
   Date:   Thu Nov 15 19:05:42 2012 +0100

       Skeleton for the new project.

   diff --git a/greeter.py b/greeter.py
   new file mode 100755
   index 0000000..b96deee
   --- /dev/null
   +++ b/greeter.py
   @@ -0,0 +1,6 @@
   +#!/usr/bin/env python
   +
   [...]

Iniziamo a lavorarci (1)
------------------------

.. class:: handout

   Iniziamo a lavorare al progetto, riempiendo qualche file.

``greeter/greeter.py``::

   class Greeter:
       """ """

       def greet(self):
           print("Hello World!")

Iniziamo a lavorarci (2)
------------------------

``greeter.py``::

   #!/usr/bin/env python

   import greeter

   def main():
       grt = greeter.Greeter()
       grt.greet()

   if __name__ == '__main__': main()

Diamo in pasto a git (1)
------------------------

.. class:: handout

   E vediamo di nuovo il workflow quotidiano: aggiungiamo le modifiche 
   fatte alla staging area; questa volta aggiungiamo l'opzione ``-p``
   a ``git add``, in modo da verificare pezzo per pezzo che modifiche
   stiamo aggiungendo.

::

   $ git add -p greeter.py greeter/greeter.py
   diff --git a/greeter.py b/greeter.py
   index b102561..15faef1 100755
   --- a/greeter.py
   +++ b/greeter.py
   @@ -1,7 +1,10 @@
    #!/usr/bin/env python3
    
   +import greeter
   +
    def main():
   -    pass
   +    grt = greeter.Greeter()
   +    grt.greet()
    
    if __name__ == '__main__': main()
    
   Stage this hunk [y,n,q,a,d,/,s,e,?]? y

   diff --git a/greeter/greeter.py b/greeter/greeter.py
   index 310fd1e..d4c4273 100644
   --- a/greeter/greeter.py
   +++ b/greeter/greeter.py
   @@ -1,2 +1,5 @@
    class Greeter:
	""" """
   +
   +    def greet(self):
   +        print("Hello World!")
   Stage this hunk [y,n,q,a,d,/,e,?]? y


Diamo in pasto a git (2)
------------------------

.. class:: handout

   E quindi possiamo creare il commit; in questo caso anziché usare un
   editor per descrivere il commit ci accontentiamo di una descrizione
   breve, passata per comodità con l'opzione ``-m``.

::

   $ git commit -m 'Generic greetings'
   [master adfbc73] Generic greetings
    2 files changed, 8 insertions(+), 1 deletion(-)
   $ git status
   # On branch master
   nothing to commit (working directory clean)
   $ git log
   commit adfbc7340ac1af8b1dc80ebb1526c7b2b9ad4d1f
   Author: Elena ``of Valhalla'' Grandi <valhalla@trueelena.org>
   Date:   Thu Nov 15 19:08:29 2012 +0100

       Generic greetings

   commit b54e94fde972281ca31a56ef0d36204addd4906b
   Author: Elena ``of Valhalla'' Grandi <valhalla@trueelena.org>
   Date:   Thu Nov 15 19:05:42 2012 +0100

       Skeleton for the new project.

amend
-----

.. class:: handout

   Se ci si è accorti di aver sbagliato qualcosa nella descrizione 
   del commit lo si può cambiare con ``git commit --amend``.

::

   $ git commit --amend

::

   Generic greetings.

   # Please enter the commit message for your changes. Lines starting
   # with '#' will be ignored, and an empty message aborts the commit.
   # On branch master
   # Changes to be committed:
   #   (use "git reset HEAD^1 <file>..." to unstage)
   #
   #       modified:   greeter.py
   #       modified:   greeter/greeter.py

::

   [master 8cdccd9] Generic greetings.
    2 files changed, 8 insertions(+), 1 deletion(-)

.. class:: handout

   Notare come l'identificativo del commit sia cambiato: di fatto 
   ``git commit --amend`` cancella l'ultimo commit e ne crea 
   uno nuovo. 

   Questo significa che questo comando non si può usare nel caso 
   in cui si sia già distribuito in qualche modo il commit in questione, 
   dato che la cosa può causare problemi negli altri repository.

gitignore
---------

.. class:: handout

   Lavorando al progetto capita che si generino file che si vogliono
   ignorare, ad esempio i risultati di compilazione o i file nascosti
   dell'editor: basta aggiungerli al file ``.gitignore`` perché non
   vengano considerati.

::

   $ ./greeter.py 
   Hello World!
   $ git status
   On branch master
   Untracked files:
     (use "git add <file>..." to include in what will be committed)

	   .greeter.py.swp
	   greeter/__pycache__/

   nothing added to commit but untracked files present (use "git add" to track)
   $ echo "*.sw?" >> .gitignore
   $ echo "__pycache__" >> .gitignore
   $ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
   
          .gitignore
   nothing added to commit but untracked files present (use "git add" to track)
   $ git add .gitignore
   $ git commit -m '.gitignore: ignore generated files.

Aggiungere funzionalità
-----------------------

.. class:: handout

    Vogliamo aggiungere al nostro progetto la capacità di salutare 
    persone diverse; dato che dobbiamo fare un po' di modifiche, 
    perché non creare un nuovo *feature branch*?

    Questo è il workflow naturale per git: ogni nuova funzionalità 
    viene sviluppata a parte in un branch apposito, e poi 
    integrata nel branch principale, che in questo modo rimane 
    sempre funzionante.

::

    $ git checkout -b people

``greeter/greeter.py``::

    class Greeter:
        """ """

        def greet(self,greetee="World"):
            print "Hello %s!"%gretee

::

   $ git add greeter/greeter.py
   $ git commit -m 'greeter/greeter.py: support for multiple greetees.'


Aggiunte successive (1)
-----------------------

.. class:: handout

   Finiamo le modifiche di cui ci stavamo occupando, committiamo.

``greeter.py``::

    #!/usr/bin/env python

    import sys

    import greeter

    def main():
        grt = greeter.Greeter()
        try:
            grt.greet(sys.argv[1])
        except IndexError:
            grt.greet()

    if __name__ == '__main__': main()

Aggiunte successive (1)
-----------------------

::

   $ git add greeter.py
   $ git commit -m 'greeter.py: support for a custom greetee.'
   [people 59b9d39] greeter.py: support for a custom greetee.
    1 file changed. 6 insertions(+). 1 deletion(-)

Bugfixing della versione stabile
--------------------------------

.. class:: handout

   Qualcuno ci fa notare che nella versione "stabile" del nostro programma 
   c'è un errore: una riga di documentazione vuota. Rimediamo subito!

::

   $ git checkout master
   Switched to branch 'master'

``greeter/greeter.py``::

   class Greeter:
       """This class greets people."""

       def greet(self):
           print "Hello World!"

::

   $ git add greeter/greeter.py
   $ git commit -m 'greeter/greeter.py: docstring for the class'
   [master cdef61b] greeter/greeter.py: docstring for the class
    1 file changed, 1 insertion(+), 1 deletion(-)


Reintegriamo in master (1)
--------------------------

.. class:: handout

   Adesso che la funzionalità è completa possiamo reintegrarla nel branch 
   master: con ``gitk --all`` possiamo vedere la situazione attuale.

::

   $ git checkout people
   Switched to branch 'people'
   $ gitk --all

.. figure:: images/gitk01.png

.. class:: handout

   Notiamo che al momento il branch people parte da un commit di master 
   che non è l'ultimo: questo non è un problema per riportarlo in master, 
   ma causa un commit fittizio con il quale si descrive il merge.

   Dato che il branch people non è stato pubblicato da nessuna parte, 
   possiamo invece barare e portarlo a nascere dall'ultimo commit di master.

::

   $ git log
   commit 59b9d3971db8cb872c798b215365b22fb20aa5a7
   [...]
   commit d78d34010156781d20ef194a62f00d4eb9edb26b

Reintegriamo in master (2)
--------------------------

::

   $ git rebase master
   First, rewinding head to replay your work on top of it...
   Applying: greeter/greeter.py: support for multiple greetees
   Using index info to reconstruct a base tree...
   Falling back to patching base and 3-way merge...
   Auto-merging greeter/greeter.py
   Applying: greeter.py: support for a custom greetee.
   $ git log
   commit 5a23f44b8492f41f6a4834b959111b924efa905c
   [...]
   commit 2229a1833b2dd00922978140d5b7e16688408ee1
   $ gitk --all

.. figure:: images/gitk02.png

.. class:: handout

   I commit hanno cambiato identificativo, non sono più gli stessi di prima, 
   ma almeno possiamo vedere che il nostro branch è la prosecuzione 
   naturale di master.

Reintegriamo in master (3)
--------------------------

.. class:: handout

   Già che ci siamo, però, possiamo decidere che i due commit riguardano 
   la stessa modifica, per cui possiamo unirli in un commit solo.

::

   $ git rebase -i master

::

   pick 2229a18 greeter/greeter.py: support for multiple greetees
   squash 5a23f44 greeter.py: support for a custom greetee.

   # Rebase cdef61b..5a23f44 onto cdef61b
   #
   # Commands:
   #  p, pick = use commit
   #  r, reword = use commit, but edit the commit message
   #  e, edit = use commit, but stop for amending
   #  s, squash = use commit, but meld into previous commit
   #  f, fixup = like "squash", but discard this commit's log message
   #  x, exec = run command (the rest of the line) using shell
   #
   # These lines can be re-ordered; they are executed from top to bottom.
   #
   # If you remove a line here THAT COMMIT WILL BE LOST.
   # However, if you remove everything, the rebase will be aborted.
   #

Reintegriamo in master (3a)
---------------------------

::

   Support for a custom greetee.
   # This is a combination of 2 commits.
   # The first commit's message is:

   # This is the 2nd commit message:

   # Please enter the commit message for your changes. Lines starting
   # with '#' will be ignored, and an empty message aborts the commit.
   #
   # Author:    Elena of Valhalla'' Grandi <valhalla@trueelena.org>
   #
   # Not currently on any branch.
   # Changes to be committed:
   #   (use "git reset HEAD <file>..." to unstage)
   #
   #       modified:   greeter.py
   #       modified:   greeter/greeter.py
   #

Reintegriamo in master (3b)
---------------------------

::

   ".git/COMMIT_EDITMSG" 18L, 509C written
   [detached HEAD ca91dc9] Support for a custom greetee.
    Author: Elena of Valhalla'' Grandi <valhalla@trueelena.org>
    2 files changed, 8 insertions(+), 3 deletions(-)
   Successfully rebased and updated refs/heads/people.

Reintegriamo in master (4)
--------------------------

.. class:: handout

   A questo punto il nostro branch è pronto per essere reinserito in 
   master.

::

   $ git log
   commit ca91dc9944e003ff47ec58464f3ebbb2ffdb8cfa
   [...]
   $ gitk --all

.. figure:: images/gitk03.png

Reintegriamo in master (5)
--------------------------

::

   $ git checkout master
   Switched to branch 'master'
   $ git merge people
   Updating cdef61b..ca91dc9
   Fast-forward
    greeter.py         |    7 ++++++-
    greeter/greeter.py |    4 ++--
    2 files changed, 8 insertions(+), 3 deletions(-)
   $ git branch -d people
   Deleted branch people (was ca91dc9).
   $ gitk -a

.. figure:: images/gitk04.png

Lavoriamo con altri
-------------------

.. class:: handout

   Un amico si offre di aiutarci nello sviluppo: vogliamo passargli
   una copia del repository

   Niente di più semplice: colleghiamo un disco esterno, da quello
   cloniamo il repository e il nostro amico potrà lavorare su quello.

::

   $ cd $USB_DISK
   $ git clone /home/[...]/greeter
   Cloning into 'greeter'...
   done.
   $ cd greeter
   $ git branch
   * master
   $ git branch -a
   * master
     remotes/origin/HEAD -> origin/master
     remotes/origin/master
     remotes/origin/people

.. class:: handout

   Con il comando ``git branch`` scopriamo che il clone ha già preso 
   come branch corrente quello che stavamo usando sul primo repository, 
   e con l'opzione ``-a`` possiamo vedere tutti i branch che abbiamo 
   a disposizione.

   Con git ogni copia comprende tutta la storia di tutti i branch 
   disponibili nel repository che si è copiato, e quindi è possibile 
   continuare a lavorare anche se ci si dovesse trovare senza connessione 
   ad internet. Inoltre ogni clone del repository è un backup completo, 
   utile nel caso in cui succeda qualcosa ad un hard disk.

Ora di rientrare (1)
--------------------

.. class:: handout

   Il nostro amico ci riporta l'hard disk, lo ricolleghiamo al pc e
   cerchiamo di riportare le modifiche dal repository esterno al
   nostro iniziale con ``git push``, e ci accorgiamo però di un problema.

::

   $ git push
   Counting objects: 5, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (3/3), done.
   Writing objects: 100% (3/3), 487 bytes, done.
   Total 3 (delta 0), reused 0 (delta 0)
   Unpacking objects: 100% (3/3), done.
   remote: error: refusing to update checked out branch: refs/heads/people
   remote: error: By default, updating the current branch in a non-bare repository
   remote: error: is denied, because it will make the index and work tree inconsistent
   remote: error: with what you pushed, and will require 'git reset --hard' to match
   remote: error: the work tree to HEAD.
   remote: error: 
   remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
   remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
   remote: error: its current branch; however, this is not recommended unless you
   remote: error: arranged to update its work tree to match what you pushed in som
   remote: error: other way.
   remote: error: 
   remote: error: To squelch this message and still keep the default behaviour, se
   remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
   To /home/[...]/greeter/
    ! [remote rejected] people -> people (branch is currently checked out)
   error: failed to push some refs to '/home/[...]/greeter/'

Ora di rientrare (2)
--------------------

.. class:: handout

   C'è un problema: git non permette di fare push che dovrebbero modificare 
   ciò che c'è nella *working copy* dell'altro repository; una soluzione 
   sarebbe richiedere l'aggiornamento con il comando ``git pull`` 
   dal repository sul PC, ma richiede un po' di configurazione. 
   Per ora usiamo una soluzione veloce:

::

   $ cd /home/[...]/greeter/
   $ git checkout master
   $ cd -
   $USB_KEY/greeter
   $ git push
   Counting objects: 5, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (3/3), done.
   Writing objects: 100% (3/3), 487 bytes, done.
   Total 3 (delta 0), reused 0 (delta 0)
   Unpacking objects: 100% (3/3), done.
   To /home/[...]/greeter/
      d78d340..59b9d39  people -> people
   $ git log
   commit 59b9d3971db8cb872c798b215365b22fb20aa5a7
   [...]
   $ cd /home/[...]/greeter/
   $ git checkout people
   Switched to branch 'people'
   $ git  log
   commit 59b9d3971db8cb872c798b215365b22fb20aa5a7

Un bel backup
-------------

.. class:: handout

   Se abbiamo in casa un computer, magari sempre acceso, al quale possiamo 
   accedere via ssh, possiamo usarlo come server su cui mettere 
   un nostro repository "centrale" da usare per gestire il lavoro da 
   più server diversi, ma anche come ulteriore copia di backup.

::

   $ ssh $SERVER
   $ mkdir -p git/greeter.git
   $ cd git/greeter.git
   $ git init --bare
   Initialized empty Git repository in /home/[...]/git/greeter.git/

::

   $ git remote add backup $SERVER:git/greeter.git
   $ git push backup master
   Counting objects: 23, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (20/20), done.
   Writing objects: 100% (23/23), 2.24 KiB, done.
   Total 23 (delta 2), reused 0 (delta 0)
   Unpacking objects: 100% (23/23), done.
   To $SERVER:git/greeter.git/
    * [new branch]      master -> master

Finalmente pubblichiamo
-----------------------

.. class:: handout

::

   $ $BROWSER http://github.com
   [...]

::

   $ git remote add origin git@github.com:greeter/greeter.git
   $ git push -u origin master
   Counting objects: 23, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (20/20), done.
   Writing objects: 100% (23/23), 2.24 KiB, done.
   Total 23 (delta 2), reused 0 (delta 0)
   Unpacking objects: 100% (23/23), done.
   To git@github.com:greeter/greeter.git
    * [new branch]      master -> master
      Branch master set up to track remote branch master from origin.


Alternative
-----------

.. class:: handout

Alternative:

* http://repo.or.cz/
* gitolite_ + gitweb_ self-hosted
* gitolite_ + cgit_ self-hosted

.. _gitolite: http://gitolite.com/gitolite/
.. _gitweb: https://git-scm.com/docs/gitweb.html
.. _cgit: https://git.zx2c4.com/cgit/about/

Altra documentazione
--------------------

* https://git-scm.com/doc

Domande?
--------

..
   vim: set filetype=rst: