SlideShare a Scribd company logo
1 of 29
Introduzione a Git 9 Giugno
2016
Sponsored by
Sponsor
Paolo Fulgoni
JAVA
Desktop
app
.Net
http://about.me/paolofulgoni
Cos’è GIT?
• SCM: Source Control Management
• Inventato da Linus Torvalds
• git == ??
• Ideato per la collaborazione
• Command-line tool
 scripting!
• Molte GUI disponibili
Intro
1/24
Idiota
SCM centralizzato
Dev #1
Dev #2
Working
copy
Working
copy
Central
repo
Intro
2/24
SCM distribuito (esempio centralizzato)
Dev #1
Dev #2
Working
copy
Working
copy
Central
repo
Local
repo
Local
repo
Intro
3/24
SCM distribuito: vantaggi (alcuni)
• Connettività non blocca il lavoro
• Operazioni in locale rapide
• Lavorare in privato, poi decidere cosa pubblicare
• No single point of failure
Intro
4/24
Installazione
• Installer/pacchetto per tutti i sistemi operativi
• No server, no demoni/servizi in background
• Configurare username e email
Repo locale
5/24
Creazione di un repo
• Immediato, no richiesta a sys admin
• Cartella [.git]: il repo è tutto lì!
Repo locale
6/24
git init  crea il repository
Preparazione di un commit
• Commit = instantanea del mio progetto
• Passaggio intermedio: staging area (o index)
Repo locale
7/24
git add
git reset
 aggiunge allo stage
 ripulisce lo stage
Creazione del commit
• Attributi del commit
• Parent: commit da cui è stato creato
• Hash: identificativo universale del commit
• …
• HEAD: puntatore al commit corrente
git commit  crea… il commit
Repo locale
8/24
Esaminare il repository
git status  mostra stato working directory e stage
Repo locale
9/24
git log  mostra storico dei commit
git checkout  carica un commit presente nel repo
[DEMO]
Repo locale
10/24
Annullare le modifiche
git revert <commit>
 annullo modifiche di un unico commit
aggiungendo un nuovo commit
git reset <commit>
 sposto il branch corrente al commit desiderato
scartando i commit
Repo locale
11/24
Non distruttivo
Distruttivo
Repo locale
12/24
[DEMO]
Branch
• branch
• staccarsi dalla linea di sviluppo principale
• lavorare su una nuova linea indipendente
• In git: branch == puntatore ad un commit
• master è il default branch
Repo locale
13/24
Creare un branch
git branch
 crea/rimuove un branch
git checkout <branch>
 sposta HEAD su un branch
Repo locale
14/24
Merge di un branch
• Fast-forward: sposta il puntatore in avanti
• 3-way merge: crea un nuovo commit con due genitori
git merge  unisce due branch
Repo locale
15/24
Merge fast-forward
prima dopo
Repo locale
16/24
Merge 3-way
prima dopo
Repo locale
17/24
Repo locale
18/24
[DEMO]
Sync
19/24
Repository remoti
• repo sono mondi isolati, che possono sincronizzarsi
• remote: link ad altro repo con il quale posso sincronizzare
• origin: nome default repo remoto
• bare repo: repo senza working folder
git remote
 aggiunge/rimuove un repo remoto
Inviare ad un repo remoto
Sync
20/24
git push  allinea branch remoto al branch locale (inviando commit)
prima dopo
Ora sapete come comportarvi…
Sync
21/24
Ricevere da un repo remoto
Sync
22/24
git clone  clona un intero repo remoto
git fetch  importa i commit da un repo remoto nel repo locale
git pull  allinea branch locale ad un branch remoto (fetch + merge)
Fetch e Pull
Sync
23/24
prima fetch pull
Sync
24/24
[DEMO]
GRAZIE PER L’ATTENZIONE!
[DOMANDE?]
credits
• Git homepage
https://git-scm.com
• Git Pro Book
https://git-scm.com/book
• Getting Git Right (by Atlassian)
https://www.atlassian.com/git/
• GitHub Training Kit
https://github.com/github/training-kit

More Related Content

What's hot

Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semverMauro Servienti
 
Dot netcampus2015 green-template
Dot netcampus2015 green-templateDot netcampus2015 green-template
Dot netcampus2015 green-templateDotNetCampus
 
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NET
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NETLe novità di Visual Studio 2015 per lo sviluppatore ASP.NET
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NETEmanuele Bartolesi
 
Dal requisito all'implementazione @ CD2010
Dal requisito all'implementazione @ CD2010Dal requisito all'implementazione @ CD2010
Dal requisito all'implementazione @ CD2010Mauro Servienti
 
Keep calm and deploy
Keep calm and deployKeep calm and deploy
Keep calm and deployKlab
 
DevOps by examples - Agile O'Day 2017
DevOps by examples - Agile O'Day 2017DevOps by examples - Agile O'Day 2017
DevOps by examples - Agile O'Day 2017Giulio Vian
 
Continuous Deployment - Agile Day 2010
Continuous Deployment - Agile Day 2010Continuous Deployment - Agile Day 2010
Continuous Deployment - Agile Day 2010migratore
 
Php Day 2009:Un Salto Nel Buio
Php Day 2009:Un Salto Nel BuioPhp Day 2009:Un Salto Nel Buio
Php Day 2009:Un Salto Nel Buiopietrobr
 
CruiseControl.net in un progetto reale
CruiseControl.net in un progetto realeCruiseControl.net in un progetto reale
CruiseControl.net in un progetto realeDotNetMarche
 
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...Marco Amendola
 
Creare App per Office 365 con ASP.NET MVC 5
Creare App per Office 365 con ASP.NET MVC 5Creare App per Office 365 con ASP.NET MVC 5
Creare App per Office 365 con ASP.NET MVC 5Emanuele Bartolesi
 
.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il MobilePietro Libro
 
What’s my destiny vSphere 6 @ VMUG.IT 20150304
What’s my destiny vSphere 6 @ VMUG.IT 20150304What’s my destiny vSphere 6 @ VMUG.IT 20150304
What’s my destiny vSphere 6 @ VMUG.IT 20150304VMUG IT
 

What's hot (15)

Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
 
Dot netcampus2015 green-template
Dot netcampus2015 green-templateDot netcampus2015 green-template
Dot netcampus2015 green-template
 
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NET
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NETLe novità di Visual Studio 2015 per lo sviluppatore ASP.NET
Le novità di Visual Studio 2015 per lo sviluppatore ASP.NET
 
Dal requisito all'implementazione @ CD2010
Dal requisito all'implementazione @ CD2010Dal requisito all'implementazione @ CD2010
Dal requisito all'implementazione @ CD2010
 
Keep calm and deploy
Keep calm and deployKeep calm and deploy
Keep calm and deploy
 
DevOps by examples - Agile O'Day 2017
DevOps by examples - Agile O'Day 2017DevOps by examples - Agile O'Day 2017
DevOps by examples - Agile O'Day 2017
 
Php for ASP.NET Developers
Php for ASP.NET DevelopersPhp for ASP.NET Developers
Php for ASP.NET Developers
 
Continuous Deployment - Agile Day 2010
Continuous Deployment - Agile Day 2010Continuous Deployment - Agile Day 2010
Continuous Deployment - Agile Day 2010
 
Php Day 2009:Un Salto Nel Buio
Php Day 2009:Un Salto Nel BuioPhp Day 2009:Un Salto Nel Buio
Php Day 2009:Un Salto Nel Buio
 
CruiseControl.net in un progetto reale
CruiseControl.net in un progetto realeCruiseControl.net in un progetto reale
CruiseControl.net in un progetto reale
 
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...
Guarda, senza mani! Automatizzare build e rilasci con Powershell senza farsi ...
 
Creare App per Office 365 con ASP.NET MVC 5
Creare App per Office 365 con ASP.NET MVC 5Creare App per Office 365 con ASP.NET MVC 5
Creare App per Office 365 con ASP.NET MVC 5
 
.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile
 
What’s my destiny vSphere 6 @ VMUG.IT 20150304
What’s my destiny vSphere 6 @ VMUG.IT 20150304What’s my destiny vSphere 6 @ VMUG.IT 20150304
What’s my destiny vSphere 6 @ VMUG.IT 20150304
 
Alfresco su misura
Alfresco su misuraAlfresco su misura
Alfresco su misura
 

Viewers also liked

Azure Application Insights
Azure Application InsightsAzure Application Insights
Azure Application InsightsKlab
 
Database under source control
Database under source controlDatabase under source control
Database under source controlKlab
 
There is a bot for that
There is a bot for thatThere is a bot for that
There is a bot for thatKlab
 
Don’t await … try async/await !
Don’t await … try async/await !Don’t await … try async/await !
Don’t await … try async/await !Klab
 
Introduzione a ReactiveX
Introduzione a ReactiveXIntroduzione a ReactiveX
Introduzione a ReactiveXKlab
 
The five dysfunctions of a team
The five dysfunctions of a teamThe five dysfunctions of a team
The five dysfunctions of a teamKlab
 

Viewers also liked (6)

Azure Application Insights
Azure Application InsightsAzure Application Insights
Azure Application Insights
 
Database under source control
Database under source controlDatabase under source control
Database under source control
 
There is a bot for that
There is a bot for thatThere is a bot for that
There is a bot for that
 
Don’t await … try async/await !
Don’t await … try async/await !Don’t await … try async/await !
Don’t await … try async/await !
 
Introduzione a ReactiveX
Introduzione a ReactiveXIntroduzione a ReactiveX
Introduzione a ReactiveX
 
The five dysfunctions of a team
The five dysfunctions of a teamThe five dysfunctions of a team
The five dysfunctions of a team
 

Similar to Introduzione a git

Introduzione a Git e GitLab
Introduzione a Git e GitLabIntroduzione a Git e GitLab
Introduzione a Git e GitLabYefry Figueroa
 
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.Git/Continuous Integration/Docker: la terna dello sviluppo moderno.
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.Gerardo Di Iorio
 
Git Flow - Un modello di branching che funziona
Git Flow - Un modello di branching che funzionaGit Flow - Un modello di branching che funziona
Git Flow - Un modello di branching che funzionaInnoteam Srl
 
Solo un server domino può sopportare così tanto carico e continuare a funzionare
Solo un server domino può sopportare così tanto carico e continuare a funzionareSolo un server domino può sopportare così tanto carico e continuare a funzionare
Solo un server domino può sopportare così tanto carico e continuare a funzionareAndreas Ponte
 
Git – lo stupido gestore di contenuti
Git – lo stupido gestore di contenutiGit – lo stupido gestore di contenuti
Git – lo stupido gestore di contenutiGiulio Caccin
 
Introduzione a Drupal 7 - 14/03/2013
Introduzione a Drupal 7 - 14/03/2013Introduzione a Drupal 7 - 14/03/2013
Introduzione a Drupal 7 - 14/03/2013Alessandro del Gobbo
 
DbUp - A real case of database migration
DbUp - A real case of database migrationDbUp - A real case of database migration
DbUp - A real case of database migrationAndrea Cirioni
 
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...festival ICT 2016
 
Development process
Development processDevelopment process
Development processEmidio Croci
 

Similar to Introduzione a git (20)

Git e GitHub
Git e GitHubGit e GitHub
Git e GitHub
 
Introduzione a Git
Introduzione a GitIntroduzione a Git
Introduzione a Git
 
Introduzione a Git e GitLab
Introduzione a Git e GitLabIntroduzione a Git e GitLab
Introduzione a Git e GitLab
 
Emerasoft Git quickstart
Emerasoft Git quickstartEmerasoft Git quickstart
Emerasoft Git quickstart
 
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.Git/Continuous Integration/Docker: la terna dello sviluppo moderno.
Git/Continuous Integration/Docker: la terna dello sviluppo moderno.
 
Quickr In Real Life - casi di successo di QuickR
 Quickr In Real Life - casi di successo di QuickR Quickr In Real Life - casi di successo di QuickR
Quickr In Real Life - casi di successo di QuickR
 
Git Flow - Un modello di branching che funziona
Git Flow - Un modello di branching che funzionaGit Flow - Un modello di branching che funziona
Git Flow - Un modello di branching che funziona
 
Git best practices
Git best practicesGit best practices
Git best practices
 
Solo un server domino può sopportare così tanto carico e continuare a funzionare
Solo un server domino può sopportare così tanto carico e continuare a funzionareSolo un server domino può sopportare così tanto carico e continuare a funzionare
Solo un server domino può sopportare così tanto carico e continuare a funzionare
 
Git – lo stupido gestore di contenuti
Git – lo stupido gestore di contenutiGit – lo stupido gestore di contenuti
Git – lo stupido gestore di contenuti
 
Introduzione a Drupal 7 - 14/03/2013
Introduzione a Drupal 7 - 14/03/2013Introduzione a Drupal 7 - 14/03/2013
Introduzione a Drupal 7 - 14/03/2013
 
Git
GitGit
Git
 
Controllo di versione e Git
Controllo di versione e GitControllo di versione e Git
Controllo di versione e Git
 
DbUp - A real case of database migration
DbUp - A real case of database migrationDbUp - A real case of database migration
DbUp - A real case of database migration
 
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...
festival ICT 2013: Windows Server 2012 R2: Ottimizzare l’infrastruttura con H...
 
Docker & DevOps
Docker  & DevOpsDocker  & DevOps
Docker & DevOps
 
Git for dummies
Git for dummiesGit for dummies
Git for dummies
 
Introduzione a Git
Introduzione a GitIntroduzione a Git
Introduzione a Git
 
Xamarin DevOps
Xamarin DevOpsXamarin DevOps
Xamarin DevOps
 
Development process
Development processDevelopment process
Development process
 

Introduzione a git