TFS - Quale source control

Preview:

Citation preview

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Non esiste Microsoft Git

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Cosa scelgo?

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

VCS – Paradigmi di basePro Contro

Check-inCheck-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 vieneda 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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

TFVC > Git / Git > TFVC

Git TFVC

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Debbo reimparare tutto?

Supporto Nativo in

Visual Studio Confort Zone

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

demoPrimi passi con Git e Visual Studio

#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

#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

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Git no quando?Quando dovreste evitare di usare git

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Siete confortevoli con il VCS attuale

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

La struttura cartelle non è ben organizzata

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Il team ha poco training su VCS

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Git si quando?Quali sono i segnali che fanno capire che potreste avere bisogno di Git

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Necessità di lavo offline locale

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Avete abusato del branching

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Il VCS attuale vi va stretto

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Usate tecnologie eterogenee

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Vale la pena provarlo?Perché potrebbe essere utile iniziare a «familiarizzare» con Git

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Github e open source

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Supporto a scenari misti

TFVC

SVN

Git-tf

Git svn

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Git come «ponte» tra mondi

Team Foundation Server / ServiceTeam Project

Git TFVC

WI Build …3rd party

Local

Repo

Remote

Remote

SVNGit Svn

Git Tf

TFVC

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Come switchareCredo che Git sia lo strumento giusto, ma come introdurlo?

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Evitare switch immediati

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Git-tf per acquisire familiarità

Usare Git in locale

mantenendo il

centralizzato

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Training e progetti pilota

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Decidere una strategia (es GitFlow)

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Gitflow

• http://nvie.com/posts/a-successful-git-branching-model/

#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à

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Git 101Una serie di informazioni «minimali» per capire meglio perché Git è differente da TFVC

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Un utile paradigma

Git crea snapshot di una cartella

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Una sequenza di snapshot

Commits

Ogni commit

rappresenta un

immagine della

cartella

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Cosa è un commit

802992c ab352fc b426dca

HEAD

Modifiche locali Staging Area

a536dbc

#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

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Ma ... se … Metto un altro puntatore?

802992c ab352fc b426dca

Modifiche locali Staging Area

a536dbc

masterHEAD test

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Un repository Git è un DirectedAcyclic Graph

802992c ab352fc B426dca

abd34ea

a536dbc

test

HEADmaster

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

ConflittiCosa accade con alberi incompatibili

#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

#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 binarief3456

master

master

master

#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

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

802992c ab352fc B426dca

12ab456

Ef3456

Gestire il conflitto – invio al server

802992c ab352fc B426dca

12ab456

Ef3456Ora si può tentare

un nuovo push al

server

master

fe34bdEf3456

origin/master

fe34bd

12ab456

master

fe34bd

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

RebasePerché non si vive di solo pull

#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

#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

#CDays14 – Roma - 23, 24 e 25 Settembre 2014

Q&ATutto 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

Recommended