Brown Bag Lunch Tours @ CEFIM - Git pour tous

69
Cedric Gatay - [email protected] 1 Git pour tous vraiment tous…

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

Page 1: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Git pour tousvraiment tous…

Page 2: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Cedric Gatay

• Code-Troopers

• Packt

• Polytech’Tours

• github.com/CedricGatay

• @Cedric_Gatay

2

Page 3: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

Page 4: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Gestion de versions

• Travailler à plusieurs

• Consulter l’historique

• Résoudre les conflits

4

Page 5: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Concepts

• Repository

• endroit où les fichiers sont stockés

• local / distant

• contient tout

5

Page 6: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Concepts

• Commit

• opération sur le repository

6

Page 7: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Concepts

• Branch

• ligne de développement

7

Page 8: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Concepts

• Merge

• point de jonction entre commits / branches

8

Page 9: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Concepts

• Tag

• nom associé à un commit

9

Page 10: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Problématique

• 10 développeurs

• 3 fonctionnalités en parallèle

• 1 bug client par semaine

10

Page 11: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Organisation

• Branches

• dev, feature1, feature2, feature3, stable

• Chacun travaille sur une branche

11

Page 12: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

Page 13: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Version Control System

• Client / Serveur

13

Page 14: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Version Control System

• Client / Serveur

• Concurrent Version System

13

Page 15: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Version Control System

• Client / Serveur

• Concurrent Version System

• SubVersioN

13

Page 16: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Decentralized VCS

• Chaque noeud possède tout

• Peer to peer

14

Page 17: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

DVCS

• Bazaar

• Mercurial

• Git

15

Page 18: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

rien que ça…

16

Page 19: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

17

Page 20: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Réparti

• Commit

• Consulter l’historique

• Changer de branche

• Merge

• Hors ligne !

18

Page 21: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

19

Page 22: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Open Source

• 2005 par Linus Torvalds

• Kernel Linux

• Philosophie Unix dans la conception

• .git

20

Page 23: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Atouts

• N’enregistre pas les différences

• Rapide

• Intelligent

• Convient pour tout projet

21

Page 24: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Page 25: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Github

• A popularisé Git

• Réseau social de développeurs

• Coeur de beaucoup de projets OSS

23

Page 26: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

En pratiqueEt pas seulement pour les développeurs…

Page 27: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Installation

• Gestionnaire de paquets

• http://git-scm.com

25

Page 28: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Configuration

26

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

Page 29: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email [email protected]

Page 30: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email [email protected]$ cat ~/.gitconfig

Page 31: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Configuration

26

$ git config --global user.name "Cedric Gatay"$ git config --global user.email [email protected]$ cat ~/.gitconfig[user] email = [email protected] name = Cedric Gatay

Page 32: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

27

$ git init

Page 33: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

27

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

Page 34: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

27

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

Page 35: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

27

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

Page 36: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

28

$ git log

Page 37: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

28

$ git log$ git status

Page 38: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

28

$ git log$ git status$ git diff

Page 39: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Premier essai

28

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

Page 40: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et les branches ?

29

$ git branch bug1

Page 41: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et les branches ?

29

$ git branch bug1$ git checkout bug1

Page 42: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et les branches ?

29

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

Page 43: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et les branches ?

29

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

Page 44: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et les branches ?

29

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

Page 45: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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

Page 46: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

30

C1

Page 47: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

30

C1

master

Page 48: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

30

C1branch

master

bug1

Page 49: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

30

C1 C2

master

bug1

Page 50: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

30

C1 C2merge

master

bug1

Page 51: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

31

C1

master

bug1

Page 52: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

31

C1

C2

master

bug1

Page 53: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

31

C1 C3

C2

master

bug1

Page 54: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Visuellement

31

C1 C3

C2

C4

master

bug1

Page 55: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Synchronisation

• Plusieurs serveurs possibles

• Protocoles existants

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

32

Page 56: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Synchronisation

33

$ git fetch

Page 57: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Synchronisation

33

$ git fetch$ git push

Page 58: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Synchronisation

33

$ git fetch$ git push$ git pull

Page 59: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Avec Github

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

34

Page 60: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

GUI

• Visuel pour l’apprentissage

• Peut simplifier l’utilisation

35

Page 61: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Page 62: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Page 63: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Et moi ?

• Serveur d’entreprise SVN ?

• aucun problème

• git-svn mapping bidirectionnel

38

Page 64: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Git-SVN

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

39

Page 65: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Git-SVN

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

39

Page 66: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Git-SVN

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

39

Page 67: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Autres utilisations

• Livres : Gitbook.io

• Wiki : Gollum

• Mise en production : Heroku

40

Page 68: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

Merci

41

Page 69: Brown Bag Lunch Tours @ CEFIM - Git pour tous

Cedric Gatay - [email protected]

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