Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand,...

28

Transcript of Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand,...

Page 1: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion de versions : git

Bertrand, Clément, Laurent, Vaibhav.

Télécom ParisTech

4 mars 2011

Bertrand, Clément, Laurent, Vaibhav. ROSE 1 / 28 4 mars 2011

Page 2: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Plan

1 Introduction

2 Installer et con�gurer git

3 Les bases de git

4 Gestion de branches

5 Exemple

6 Conclusion

7 Ressources

Bertrand, Clément, Laurent, Vaibhav. ROSE 2 / 28 4 mars 2011

Page 3: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Logiciels de gestion de versions

Logiciels de gestion de versions

Principe : commits, branches, di�érences, identi�cation. . .

Avantages : travail collaboratif, sauvegarde, évolution. . .

Architecture : locale, centralisée, distribuée

Bertrand, Clément, Laurent, Vaibhav. ROSE 3 / 28 4 mars 2011

Page 4: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

InstallationCon�guration

Installation

paquets git sur debian/ubuntu

éventuellement qgit/gitk, meld/emerge/vimdi�...

con�guration

Bertrand, Clément, Laurent, Vaibhav. ROSE 4 / 28 4 mars 2011

Page 5: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

InstallationCon�guration

Con�guration

�chier de con�guration ~/.gitconfig ou en ligne decommande git config --global

user.name

user.email

core.editor

merge.tool

Bertrand, Clément, Laurent, Vaibhav. ROSE 5 / 28 4 mars 2011

Page 6: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Statut de �chiersCommandes de Base

Statut de �chiers

Source : progit.org

Bertrand, Clément, Laurent, Vaibhav. ROSE 6 / 28 4 mars 2011

Page 7: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Statut de �chiersCommandes de Base

Commandes de base

git clone

[email protected]:2011/repo.git

- cloner un dépot distant

git add - ajouter un �chier ou des changements

git rm - supprimer un �chier ou des changements

git status - a�cher l'état courant des �chiers

git commit - créer un commit avec les modi�cations ajoutées

git log - a�cher l'historique

Bertrand, Clément, Laurent, Vaibhav. ROSE 7 / 28 4 mars 2011

Page 8: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion localeInteractions avec un dépot distantMerge

Branches, pointeurs et commits

Source : progit.org

Bertrand, Clément, Laurent, Vaibhav. ROSE 8 / 28 4 mars 2011

Page 9: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion localeInteractions avec un dépot distantMerge

Commandes : branches

git branch - lister les branches

git branch <name> - créer une branche

git branch -d <name> - supprimer une branche

git checkout <branch/commit> - se placer sur branche ouun commit

Bertrand, Clément, Laurent, Vaibhav. ROSE 9 / 28 4 mars 2011

Page 10: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion localeInteractions avec un dépot distantMerge

Interactions avec un dépot distant

git fetch - se synchroniser avec le serveur sans changer

l'état courant

git push <remote> <branch>:<remotebranch> - mettre àjour une branche distante

git push <remote> :<remotebranch> - supprimer unebranche distante

Bertrand, Clément, Laurent, Vaibhav. ROSE 10 / 28 4 mars 2011

Page 11: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion localeInteractions avec un dépot distantMerge

Merge 1/2

Source : progit.org

Bertrand, Clément, Laurent, Vaibhav. ROSE 11 / 28 4 mars 2011

Page 12: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Gestion localeInteractions avec un dépot distantMerge

Merge 2/2

git checkout <branch1>

git merge <branch2>

si merge con�ict :

git status

git mergetool

git commit

git pull - fetch puis merge

Bertrand, Clément, Laurent, Vaibhav. ROSE 12 / 28 4 mars 2011

Page 13: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Exemple

Dépot distant :

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

remote

Bertrand, Clément, Laurent, Vaibhav. ROSE 13 / 28 4 mars 2011

Page 14: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

origin/master

origin/b1

git clone user@host:repo.git

Bertrand, Clément, Laurent, Vaibhav. ROSE 14 / 28 4 mars 2011

Page 15: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

masterb2

cac..

baf..

b1

origin/master

origin/b1

git checkout master

git branch b2git checkout b2

Bertrand, Clément, Laurent, Vaibhav. ROSE 15 / 28 4 mars 2011

Page 16: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

d08..

b2

cac..

baf..

b1

origin/master

origin/b1

faire changements

git add <files>git commit

Bertrand, Clément, Laurent, Vaibhav. ROSE 16 / 28 4 mars 2011

Page 17: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

mastera49..

d08..

b2

cac..

baf..

b1

origin/master

origin/b1

faire changements

git add <files>git commit

Bertrand, Clément, Laurent, Vaibhav. ROSE 17 / 28 4 mars 2011

Page 18: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

cac..

baf..

b1

origin/master

origin/b1

faire changements

git add <files>git commit

Bertrand, Clément, Laurent, Vaibhav. ROSE 18 / 28 4 mars 2011

Page 19: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

cac..

baf..

b1

origin/master

origin/b1

origin/b2

git push origin b2

Bertrand, Clément, Laurent, Vaibhav. ROSE 19 / 28 4 mars 2011

Page 20: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

cac..

baf..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

cac..

baf..

origin/master

origin/b1

origin/b2

83d..

3a4..

b1

git rebase master b1

Bertrand, Clément, Laurent, Vaibhav. ROSE 20 / 28 4 mars 2011

Page 21: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

83d..

3a4..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

origin/m

aster

origin/b2

83d..

3a4..

b1origin/b1

git push -f origin b1

Bertrand, Clément, Laurent, Vaibhav. ROSE 21 / 28 4 mars 2011

Page 22: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2

83d..

3a4..

b1

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2origin/master

origin/b2

83d..

3a4..

b1origin/b1

git push origin b1:master

Bertrand, Clément, Laurent, Vaibhav. ROSE 22 / 28 4 mars 2011

Page 23: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

0c3..

053..

f5a..

1ed..

a3f..

bb3..

a49..

d08..

b2

local remote

0c3..

053..

f5a..

1ed..

a3f..

master

bb3..

a49..

d08..

b2 origin/masterorigin/b2

83d..

3a4..

master

83d..

3a4..

git pull origin master

git branch -D b1git push origin :b1

Bertrand, Clément, Laurent, Vaibhav. ROSE 23 / 28 4 mars 2011

Page 24: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

053..

f5a..

1ed..

bb3..

a49..

d08..

b2

local remote

053..

f5a..

1ed..

master

bb3..

a49..

d08..

b2

origin/master

origin/b2

83d..

3a4..

master

83d..

3a4..

git rebase master b2

git push -f origin b2

Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011

Page 25: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

local remoteorigin/master

053..

f5a..

1ed..

master

bb3..

a49..

d08..

83d..

3a4..

053..

f5a..

1ed..

master

bb3..

a49..

d08..

83d..

3a4..

git push origin b2:master

git branch -D b2

git push origin :b2

git pull origin master

Bertrand, Clément, Laurent, Vaibhav. ROSE 25 / 28 4 mars 2011

Page 26: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

. . .

Bertrand, Clément, Laurent, Vaibhav. ROSE 26 / 28 4 mars 2011

Page 27: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Conclusion

Flexible

Organisation

Retours en arrière

Sauvegarde sur serveur

Obligatoire

Bertrand, Clément, Laurent, Vaibhav. ROSE 27 / 28 4 mars 2011

Page 28: Gestion de versions : git · 2011-03-06 · git rebase master b2 git push -f origin b2 Bertrand, Clément, Laurent, Vaibhav. ROSE 24 / 28 4 mars 2011. Plan Introduction Installer

PlanIntroduction

Installer et con�gurer gitLes bases de git

Gestion de branchesExemple

ConclusionRessources

Ressources

Progit

Liste de serveurs git

Bertrand, Clément, Laurent, Vaibhav. ROSE 28 / 28 4 mars 2011