1. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
VS04 – TFS: Quale
source control
Gian Maria Ricci
alkampfer@nablasoft.com - @alkampfer
http://www.codewrecks.com/
http://www.getlatestversion.it/
http://blogs.ugidotnet.org/rgm
2. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Grazie a
Sponsor
3. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Tfs e git, perché?
• Richiesta di avere un source control distribuito
• Diffusione capillare e supporto su tutti i sistemi / IDE / strumenti
• Stabile, manutenuto ed in continua evoluzione
• Apertura verso l’open source
• Lavoro offline
• Easy Branching
• Integrato con TFS al pari (quasi) di TFVC
4. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Non esiste Microsoft Git
6. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Quando scegliere
• Un Team Project può utilizzare solamente TFVC oppure Git
• In approcci con «Single Team Project» questo significa scegliere il source
control all’inizio
• È comunque possibile creare un nuovo Team Project e «convertire» il
vecchio codice
• Passare da un centralizzato ad un distribuito o viceversa comporta
comunque riorganizzare/istruire/cambiare
7. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
VCS – Paradigmi di base
Pro Contro
Check-in
Check-out
• Codebase molto grandi
• Security granulare
• Controllo attività utenti
• Meno intuitivo
• Favorisce l’uso di lock
• Sempre connesso
• Editing offline
• Cross tool
• Intuitivo per chi viene
da SVN
• Meno performante per
codebase molto larghe
• No check-out lock
• Completamente offline
• Clone completo
• First Class Branching
• …
• Più complesso
• Non performante per
grandi file binari
• Necessita di più
disciplina
8. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
TFVC > Git / Git > TFVC
Git TFVC
9. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Debbo reimparare tutto?
Supporto Nativo in
Visual Studio
Confort Zone
10. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
demo
Primi passi con Git e Visual Studio
11. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Andando in profondità
Visual Studio ha un
buon supporto git,
che è in continua
evoluzione,
ma git è complesso
è va «masticato»
bene per non farsi
male
12. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Alcune considerazioni
Git Pro
Supporto IDE multiple
Multi sistema
Stack Overflow
Branching
Offline
Well Known Workflow
Git Contro
Strumenti eterogenei
Necessità di più training
Complicazione History
Strutturazione repository
Tfvc Pro
Semplice
Repository Lineare
Sopporta repo mal strutturati
Tfvc Contro
Scarso supporto branch
Nessun supporto offline
Flussi di lavoro semplici
13. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Cattive analogie TFVC <-> Git
• Git è simile a TFVC, solamente che si ha un repository locale ed uno (o
piu server remoti)
• Git pull è l’analogo di Get Latest Version (falso)
• Git push è l’analogo di Check-in (falsissimo)
• Git va approcciato come uno strumento completamente nuovo senza
nessun paradigma con VCS centralizzati
14. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Ognuno ha un repository
Tutti i repository sono
paritari
Nello scenario più semplice
un repository è considerato
il Principale
15. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Git no quando?
Quando dovreste evitare di usare git
16. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Siete confortevoli con il VCS attuale
17. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
La struttura cartelle non è ben
organizzata
18. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Il team ha poco training su VCS
19. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Git si quando?
Quali sono i segnali che fanno capire che potreste avere bisogno di Git
20. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Necessità di lavo offline locale
21. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Avete abusato del branching
22. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Il VCS attuale vi va stretto
23. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Usate tecnologie eterogenee
24. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Vale la pena provarlo?
Perché potrebbe essere utile iniziare a «familiarizzare» con Git
25. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Github e open source
26. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Supporto a scenari misti
TFVC
SVN
Git-tf
Git svn
27. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Git come «ponte» tra mondi
Team Foundation Server / Service
Team Project
Git TFVC
WI Build …
3rd party
Local
Repo
Remote
Remote
SVNGit Svn
Git Tf
TFVC
28. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Come switchare
Credo che Git sia lo strumento giusto, ma come introdurlo?
29. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Evitare switch immediati
30. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Git-tf per acquisire familiarità
Usare Git in locale
mantenendo il
centralizzato
31. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Training e progetti pilota
32. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Decidere una strategia (es GitFlow)
33. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Gitflow
• http://nvie.com/posts/a-successful-git-branching-model/
34. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Flussi di sviluppo avanzati
• https://www.atlassian.com/git/tutorials/comparing-workflows
• Git permette molti flussi di lavoro differenti
• È fortemente consigliato esaminarli attentamente prima di introdurre
git nel proprio team
• Usate (se possibile) piccoli progetti reali per comparare i flussi ed
acquisire familiarità
35. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Git 101
Una serie di informazioni «minimali» per capire meglio perché Git è
differente da TFVC
36. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Un utile paradigma
Git crea snapshot di una cartella
37. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Una sequenza di snapshot
Commits
Ogni commit
rappresenta un
immagine della
cartella
38. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Contenuto di un commit
2ab56.. ae14f.. 24d36.. 3abe5..
Foo.txt
Bar.txt
42.cs
Ptr.vcproj
Foo.txt
Bar.txt
42.cs
Ptr.vcproj
Foo.txt
Bar.txt
42.cs
Ptr.vcproj
Foo.txt
Bar.txt
42.cs
Ptr.vcproj
ID = SHA1
Bar.txt
42.cs
Foo.txt
Ptr.vcproj
Foo.txt
Bar.txt
39. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Che commit è attivo ora?
802992c ab352fc b426dca 364ba23
HEAD
In ogni momento il
puntatore HEAD identifica il
commit che rappresenta il
contenuto attuale della
cartella
40. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Cosa è un commit
802992c ab352fc b426dca
HEAD
Modifiche
locali Staging Area
a536dbc
41. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Cosa è una branch (e qui iniziamo a
divertirci veramente)
802992c ab352fc b426dca
Modifiche
locali Staging Area
a536dbc
HEAD master
42. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
La branch «master» è un puntatore
802992c ab352fc b426dca a536dbc
HEAD master
Spostare la HEAD significa
«riprstinare» uno snapshot
43. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Detatched HEAD
802992c ab352fc b426dca a536dbc
HEAD master
Una Detached HEAD è
simile ad un «get specific
version»
Da una specific version in
TFVC non potete fare un
changeset
Capitan Ovvio
44. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Ma ... se … Metto un altro puntatore?
802992c ab352fc b426dca
Modifiche
locali Staging Area
a536dbc
masterHEAD test
45. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Con più puntatori ho più versioni
802992c ab352fc b426dca
Modifiche
locali Staging Area
a536dbc
master HEAD test
abd34ea
testmaster
46. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Un repository Git è un Directed
Acyclic Graph
802992c ab352fc B426dca
abd34ea
a536dbc
test
HEADmaster
47. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Conflitti
Cosa accade con alberi incompatibili
48. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Ogni sviluppatore ha una sua master
802992c ab352fc B426dca 12ab456
802992c ab352fc B426dca ef3456
Gli sviluppatori hanno
aggiornato la master al
b426dca Ognuno ha fatto una
modifica
master
master
49. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Come si condivide il codice?
802992c ab352fc B426dca 12ab456
802992c ab352fc B426dca ef3456
802992c ab352fc B426dca ef3456
Inviare le
modifiche all’origin
significa spostare i
commit binari
ef3456
master
master
master
50. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Come si condivide il codice?
802992c ab352fc B426dca 12ab456
802992c ab352fc B426dca ef3456
802992c ab352fc B426dca ef3456
Non potete inviare
modifiche se i grafi
sono incompatibili
12ab456
master
51. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Gestire il conflitto - fetch
802992c ab352fc B426dca
12ab456
ef3456
802992c ab352fc B426dca ef3456
Il primo passo è
fare un Fetch dal
server
master
origin/master
master
52. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Gestire il conflitto - merge
802992c ab352fc B426dca
12ab456
ef3456
802992c ab352fc B426dca ef3456
Localmente si
effettua una merge
tra le branch
master
origin/master
fe34bd
master
53. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
802992c ab352fc B426dca
12ab456
Ef3456
Gestire il conflitto – invio al server
802992c ab352fc B426dca
12ab456
Ef3456
Ora si può tentare
un nuovo push al
server
master
fe34bdEf3456
origin/master
fe34bd
12ab456
master
fe34bd
54. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Rebase
Perché non si vive di solo pull
55. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Gestire il conflitto - fetch
802992c ab352fc B426dca
12ab456
ef3456
802992c ab352fc B426dca ef3456
Il primo passo è
fare un Fetch dal
server
master
origin/master
master
56. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Gestire il conflitto – and rebase
802992c ab352fc B426dca
12ab456
ef3456
802992c ab352fc B426dca ef3456
master
origin/master
master
12ab456
eb54af2
57. #CDays14 – Roma - 23, 24 e 25 Settembre 2014
Q&A
Tutto il materiale di questa sessione su
http://www.communitydays.it/
Lascia il feedback su questa sessione dal sito,
potrai essere estratto per i nostri premi!
Seguici su
Twitter @CommunityDaysIT
Facebook http://facebook.com/cdaysit
#CDays14
Notas do Editor
Slide da mostrare prima di iniziare la sessione – non rimuovere!