Introduzione a Git
-
Upload
alfonso-piscitelli -
Category
Technology
-
view
140 -
download
0
Transcript of Introduzione a Git
![Page 1: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/1.jpg)
#DevFest16
Intro to
Alfonso PiscitelliSoftware Developer
@piscitelli91
![Page 2: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/2.jpg)
#DevFest16#DevFest16
Programma
● Introduzione○ Team di sviluppo○ Problematiche da risolvere○ Version of control○ GIT
● Getting started on GIT○ Inizializzare Repository○ Aggiungere file al repo○ Il primo commit○ Sincronizzazione remota pull & push○ Branch in GIT
![Page 3: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/3.jpg)
#DevFest16#DevFest16
Introduzione
![Page 4: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/4.jpg)
#DevFest16
Un CLASSICO team di sviluppo
Caricate sul server!!
![Page 5: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/5.jpg)
#DevFest16
U CLASSICO team di sviluppo..
Un attimo, sto risolvendo un bug urgente
Sto facendo
una modifica
Meglio cazzeggiare su Facebook
va!
Datemi un
secondo!
Un CLASSICO team di sviluppo
![Page 6: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/6.jpg)
#DevFest16
Hei, c’è nessuno? Sto facendo una modifica
Fermi tutti!
Adesso ti mando le mie modifiche via mail
Ci sono!
Un MODERNO team di sviluppo
![Page 7: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/7.jpg)
#DevFest16
SERVE QUALCOSA CHE..
![Page 8: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/8.jpg)
#DevFest16
Permetta di lavorare insieme sullo stesso progetto software
SERVE QUALCOSA CHE..
![Page 9: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/9.jpg)
#DevFest16
Permetta di lavorare insieme sullo stesso FILE
SERVE QUALCOSA CHE..
![Page 10: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/10.jpg)
#DevFest16
Dia visione dell’evoluzione del progetto
SERVE QUALCOSA CHE..
![Page 11: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/11.jpg)
#DevFest16
Permetta di tornare ad un punto precedente dello sviluppo
SERVE QUALCOSA CHE..
![Page 12: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/12.jpg)
#DevFest16
Permetta di effettuare una diramazione del progetto
SERVE QUALCOSA CHE..
![Page 13: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/13.jpg)
#DevFest16
Permetta di lavorare insieme sullo stesso progetto software
Permetta di lavorare insieme sullo stesso FILE
Dia visione dell’evoluzione del progetto
Permetta di tornare ad un punto precedente dello sviluppo
Permetta di effettuare una diramazione del progetto
SERVE QUALCOSA CHE..
![Page 14: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/14.jpg)
#DevFest16
VCS - Version Control System
Inizia a scrivere un documento
Modifica una sezione del documento
Si accorge di aver modificato la sezione sbagliata
![Page 15: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/15.jpg)
#DevFest16
Tornare indietro nel tempo
Inizio Modifica1
Modifica2
Modifican
Modifican+1
![Page 16: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/16.jpg)
#DevFest16
Tornare indietro nel tempo
Inizio Modifica1
Modifica2
Modifican
Modifican+1
![Page 17: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/17.jpg)
#DevFest16
Tornare indietro nel tempo
Inizio Modifica1
Modifica2
Modifican
![Page 18: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/18.jpg)
#DevFest16#DevFest16
GIT
![Page 19: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/19.jpg)
#DevFest16
● Sistema di controllo di versione (VCS)
● VCS distribuito
● VCS particolarmente efficiente e scalabile
● Creato da Linus Torvalds
GIT?
![Page 20: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/20.jpg)
#DevFest16
● Un VCS gestisce la collaborazione al progetto
● Per monitorare lo stato del progetto
● Per poter tornare indietro nelle versioni in caso di problemi
Perché usare un VCS come GIT?
![Page 21: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/21.jpg)
#DevFest16
In poche parole...
![Page 22: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/22.jpg)
#DevFest16
Per gestire meglio il tuo progetto software
![Page 23: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/23.jpg)
#DevFest16
Inoltre, sempre più aziende usano GIT
Perché usare un VCS come GIT?
![Page 24: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/24.jpg)
#DevFest16#DevFest16
Repository Gratuiti
![Page 25: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/25.jpg)
#DevFest16#DevFest16
Getting StartedPrendiamo confidenza con GIT
![Page 26: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/26.jpg)
#DevFest16#DevFest16
Repository
Il repository nei VCS è la scatola che contiene tutte le informazioni del nostro progetto (metadati, sorgenti ecc).
![Page 27: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/27.jpg)
#DevFest16#DevFest16
Creazione di un Repository GIT
Per creare un repository su GIT apriamo un terminale e digitiamo:
git init
![Page 28: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/28.jpg)
#DevFest16#DevFest16
Creazione di un Repository GIT
Da questo momento GIT monitorerà il repository, in attesa di cambi di stato. Proviamo ad aggiungere un file
![Page 29: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/29.jpg)
#DevFest16#DevFest16
Aggiunta di un file al RepositoryE lanciamo il comando git status. Git riconoscerà l’aggiunta del nuovo file
![Page 30: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/30.jpg)
#DevFest16#DevFest16
Commit ?
● Punto di avanzamento del progetto
● Un commit rappresenta un passo avanti nel progetto
● Rende una serie di cambiamenti definitivi
● Un commit è caratterizzato da:○ I file modificati
○ Una descrizione del commit
![Page 31: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/31.jpg)
#DevFest16#DevFest16
Aggiungere file al commit
Per aggiungere un file al commit digitiamo il comando:
git add nomefile.ext
Lanciando un git-status scopriremo che il nostro file è pronto
![Page 32: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/32.jpg)
#DevFest16#DevFest16
Il primo commit non si scorda mai
git commit -m ‘descrizione del commit’
![Page 33: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/33.jpg)
#DevFest16#DevFest16
Il primo commit non si scorda mai
git commit -m ‘descrizione del commit’
![Page 34: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/34.jpg)
#DevFest16
Il primo commit non si scorda mai
Git config user.name = Alfonso
Git config user.email = [email protected]
Chi Sei?
![Page 35: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/35.jpg)
#DevFest16#DevFest16
Il primo commit non si scorda mai
git commit -m ‘descrizione del commit’
![Page 36: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/36.jpg)
#DevFest16
Sincronizzazione remota: pull & pushSincronizzazione remota: pull & push
![Page 37: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/37.jpg)
#DevFest16#DevFest16
Sincronizzazione remota: pull & push
$ git push
$ git pull
Per sincronizzare il proprio repository dal server
Per sincronizzare il server con i nostri commit
![Page 39: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/39.jpg)
#DevFest16#DevFest16
BranchDiramazioni di un progetto
![Page 40: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/40.jpg)
#DevFest16#DevFest16
Cosa è un branch
● Ogni volta che facciamo un commit salviamo lo stato del progetto in quel momento
● Può essere necessario ripartire da un punto e fare altri sviluppi
● Un branch rappresenta una diramazione del progetto
cmaster c c
![Page 41: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/41.jpg)
#DevFest16#DevFest16
Cosa è un branch
cmaster c c
c c cdev
c
Da questo momento i due rami hanno vita indipendente.
![Page 42: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/42.jpg)
#DevFest16#DevFest16
Perché un branch?
● Per lavorare autonomamente ad una parte del progetto
● Per lavorare ad una nuova feature del progetto○ Potrei lavorare sul branch master?
○ No! Se mentre aggiungi una feature devi risolvere un bug?
● Per intervenire su un bug senza compromettere gli altri sviluppi
![Page 43: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/43.jpg)
#DevFest16#DevFest16
Creazione di un branch
In git abbiamo due modi per creare un branch.
● Creare un branch partendo dal punto attuale del progetto
● Creare un branch partendo da un punto (commit) preciso del progetto
![Page 44: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/44.jpg)
#DevFest16#DevFest16
Creazione di un branch
Per creare un branch partendo dal punto attuale del progetto usiamo il comando
git branch nomeBranch
Per entrare nel ramo appena creato invece, usiamo il comando git checkout
git checkout nomeBranch
![Page 45: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/45.jpg)
#DevFest16#DevFest16
Creazione di un branch
![Page 46: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/46.jpg)
#DevFest16#DevFest16
Creazione di un branch
Per creare un branch partendo da un punto (commit) preciso del progetto, invece, dobbiamo ottenere prima l’id del commit da cui vogliamo ripartire
git log
![Page 47: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/47.jpg)
#DevFest16#DevFest16
Creazione di un branch
Per creare un branch partendo da un punto (commit) preciso del progetto, invece, dobbiamo ottenere prima l’id del commit da cui vogliamo ripartire
git log
Id del commit
![Page 48: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/48.jpg)
#DevFest16#DevFest16
Creazione di un branch
A questo punto, come prima, utilizziamo il comando git checkout, con il parametro -b.
git checkout id_del_commit -b nome_branch
![Page 49: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/49.jpg)
#DevFest16#DevFest16
Creazione di un branch
A questo punto, come prima, utilizziamo il comando git checkout, con il parametro -b.
git checkout id_del_commit -b nome_branch
N.B. Git ti sposterà direttamente nel branch appena creato
![Page 50: Introduzione a Git](https://reader031.fdocuments.in/reader031/viewer/2022021922/587e62db1a28ab2a538b664d/html5/thumbnails/50.jpg)
#DevFest16#DevFest16
Grazie per l’attenzione
@piscitelli91