Brown Bag Lunch Tours @ CEFIM - Git pour tous

Post on 05-Jul-2015

363 views 3 download

description

Slides correspondant au BrownBagLunch donné le 17/06/2014 au CEFIM à Tours : Vulgarisation de Git pour tous

Transcript of Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - c.gatay@code-troopers.com1

Git pour tousvraiment tous…

Cedric Gatay - c.gatay@code-troopers.com

Cedric Gatay

• Code-Troopers

• Packt

• Polytech’Tours

• github.com/CedricGatay

• @Cedric_Gatay

2

Cedric Gatay - c.gatay@code-troopers.com3

Qui a changé ce fichier ?Parce que je tiens réellement à le féliciter…

Cedric Gatay - c.gatay@code-troopers.com

Gestion de versions

• Travailler à plusieurs

• Consulter l’historique

• Résoudre les conflits

4

Cedric Gatay - c.gatay@code-troopers.com

Concepts

• Repository

• endroit où les fichiers sont stockés

• local / distant

• contient tout

5

Cedric Gatay - c.gatay@code-troopers.com

Concepts

• Commit

• opération sur le repository

6

Cedric Gatay - c.gatay@code-troopers.com

Concepts

• Branch

• ligne de développement

7

Cedric Gatay - c.gatay@code-troopers.com

Concepts

• Merge

• point de jonction entre commits / branches

8

Cedric Gatay - c.gatay@code-troopers.com

Concepts

• Tag

• nom associé à un commit

9

Cedric Gatay - c.gatay@code-troopers.com

Problématique

• 10 développeurs

• 3 fonctionnalités en parallèle

• 1 bug client par semaine

10

Cedric Gatay - c.gatay@code-troopers.com

Organisation

• Branches

• dev, feature1, feature2, feature3, stable

• Chacun travaille sur une branche

11

Cedric Gatay - c.gatay@code-troopers.com12

One tool to rule’em allPas tout à fait en fait…

Cedric Gatay - c.gatay@code-troopers.com

Version Control System

• Client / Serveur

13

Cedric Gatay - c.gatay@code-troopers.com

Version Control System

• Client / Serveur

• Concurrent Version System

13

Cedric Gatay - c.gatay@code-troopers.com

Version Control System

• Client / Serveur

• Concurrent Version System

• SubVersioN

13

Cedric Gatay - c.gatay@code-troopers.com

Decentralized VCS

• Chaque noeud possède tout

• Peer to peer

14

Cedric Gatay - c.gatay@code-troopers.com

DVCS

• Bazaar

• Mercurial

• Git

15

Cedric Gatay - c.gatay@code-troopers.com

Git est un système de gestion de versions réparti Open source

rien que ça…

16

Cedric Gatay - c.gatay@code-troopers.com

Git est un système de gestion de versions réparti Open source

17

Cedric Gatay - c.gatay@code-troopers.com

Réparti

• Commit

• Consulter l’historique

• Changer de branche

• Merge

• Hors ligne !

18

Cedric Gatay - c.gatay@code-troopers.com

Git est un système de gestion de versions réparti Open source

19

Cedric Gatay - c.gatay@code-troopers.com

Open Source

• 2005 par Linus Torvalds

• Kernel Linux

• Philosophie Unix dans la conception

• .git

20

Cedric Gatay - c.gatay@code-troopers.com

Atouts

• N’enregistre pas les différences

• Rapide

• Intelligent

• Convient pour tout projet

21

Cedric Gatay - c.gatay@code-troopers.com22Github

Cedric Gatay - c.gatay@code-troopers.com

Github

• A popularisé Git

• Réseau social de développeurs

• Coeur de beaucoup de projets OSS

23

Cedric Gatay - c.gatay@code-troopers.com24

En pratiqueEt pas seulement pour les développeurs…

Cedric Gatay - c.gatay@code-troopers.com

Installation

• Gestionnaire de paquets

• http://git-scm.com

25

Cedric Gatay - c.gatay@code-troopers.com

Configuration

26

$ git config --global user.name "Cedric Gatay"

Cedric Gatay - c.gatay@code-troopers.com

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email c.gatay@dmn.tld

Cedric Gatay - c.gatay@code-troopers.com

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email c.gatay@dmn.tld$ cat ~/.gitconfig

Cedric Gatay - c.gatay@code-troopers.com

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email c.gatay@dmn.tld$ cat ~/.gitconfig[user] email = c.gatay@dmn.tld name = Cedric Gatay

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

27

$ git init

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

27

$ git init$ echo "git ftw" > 1337.txt

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

27

$ git init$ echo "git ftw" > 1337.txt$ git add 1337.txt

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

27

$ git init$ echo "git ftw" > 1337.txt$ git add 1337.txt$ git commit -m"Mon premier commit"

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

28

$ git log

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

28

$ git log$ git status

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

28

$ git log$ git status$ git diff

Cedric Gatay - c.gatay@code-troopers.com

Premier essai

28

$ git log$ git status$ git diff$ git blame 1337.txt

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1$ git checkout bug1

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1$ git checkout bug1$ echo "Git FTW" > 1337.txt

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1$ git checkout bug1$ echo "Git FTW" > 1337.txt$ git commit -m"Correction message"

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1$ git checkout bug1$ echo "Git FTW" > 1337.txt$ git commit -m"Correction message"$ git checkout master

Cedric Gatay - c.gatay@code-troopers.com

Et les branches ?

29

$ git branch bug1$ git checkout bug1$ echo "Git FTW" > 1337.txt$ git commit -m"Correction message"$ git checkout master$ git merge bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

30

C1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

30

C1

master

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

30

C1branch

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

30

C1 C2

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

30

C1 C2merge

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

31

C1

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

31

C1

C2

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

31

C1 C3

C2

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Visuellement

31

C1 C3

C2

C4

master

bug1

Cedric Gatay - c.gatay@code-troopers.com

Synchronisation

• Plusieurs serveurs possibles

• Protocoles existants

file://, ssh://, git://, http://

32

Cedric Gatay - c.gatay@code-troopers.com

Synchronisation

33

$ git fetch

Cedric Gatay - c.gatay@code-troopers.com

Synchronisation

33

$ git fetch$ git push

Cedric Gatay - c.gatay@code-troopers.com

Synchronisation

33

$ git fetch$ git push$ git pull

Cedric Gatay - c.gatay@code-troopers.com

Avec Github

$ # Création d’un repository sur github.com # $ git clone git@github.com:user/repo.git $ # work.work..work... # $ git pull $ git push

34

Cedric Gatay - c.gatay@code-troopers.com

GUI

• Visuel pour l’apprentissage

• Peut simplifier l’utilisation

35

Cedric Gatay - c.gatay@code-troopers.com36SourceTree

Cedric Gatay - c.gatay@code-troopers.com37Github

Cedric Gatay - c.gatay@code-troopers.com

Et moi ?

• Serveur d’entreprise SVN ?

• aucun problème

• git-svn mapping bidirectionnel

38

Cedric Gatay - c.gatay@code-troopers.com

Git-SVN

$ git svn clone -s http://mon.svn.tld

39

Cedric Gatay - c.gatay@code-troopers.com

Git-SVN

$ git svn clone -s http://mon.svn.tld$ git svn update

39

Cedric Gatay - c.gatay@code-troopers.com

Git-SVN

$ git svn clone -s http://mon.svn.tld$ git svn update$ git svn dcommit

39

Cedric Gatay - c.gatay@code-troopers.com

Autres utilisations

• Livres : Gitbook.io

• Wiki : Gollum

• Mise en production : Heroku

40

Cedric Gatay - c.gatay@code-troopers.com

Merci

41

Cedric Gatay - c.gatay@code-troopers.com

Credits

• https://www.flickr.com/photos/dk_spook/2421009077/sizes/o

• https://www.flickr.com/photos/dunechaser/2936382027/sizes/o

• https://www.flickr.com/photos/tykva/4014209498/sizes/o

• https://www.flickr.com/photos/st3f4n/4360212268/sizes/o/

• Trademarks belong to their respective owners

42