#DevoxxFR
T'es plutôt git merge ou
git rebase ?
Jean Detoeuf
@thebignet
1
#DevoxxFR
Jean Detoeuf
Développeur freelance
Software Crafter
DDD
Agile
git
2
#DevoxxFR 3
#DevoxxFR 4
Développeur apprenant git
#DevoxxFR
git log
5
#DevoxxFR 6
Deux manières de faire un merge
#DevoxxFR 7
#DevoxxFR 8
Merge
#DevoxxFR 9
merged feature A
feature A
Merge
master
#DevoxxFR
Quand faire un merge-commit ?
• Sur les branches durables
• Pour indiquer un fait marquant :
• Release, Sprint
• Mise en production
10
#DevoxxFR 11
feature A
master
Rebase
#DevoxxFR 12
master
feature A
Rebase
#DevoxxFR 13
master
feature A
Rebase
#DevoxxFR 14
master
feature A
Rebase
#DevoxxFR
Quand faire un rebase ?
• Sur acceptation d'une pull request de feature, suivi d'un merge
fast-forward
• Lors d'un git pull
15
git config --global branch.autoSetupRebase always
git config --global pull.rebase = preserve
#DevoxxFR
conflits
16
#DevoxxFR
Eviter les conflits
• Utiliser des retours à la ligne
• Eviter de travailler sur les mêmes fichiers
• Structurer correctement l'application en séparant les
fonctionnalités dans des fichiers différents
• Se répartir le travail intelligemment dans l'équipe
• Commiter régulièrement
• Faire des branches qui ne durent pas longtemps
17
#DevoxxFR
Rebase/merge
• Reuse Recorded Resolution pour éviter les corrections identiques
18
git config --global rerere.enabled true
#DevoxxFR
Réécrire l'histoire - rebase intéractif
pick f7f3f6d changed my name a bit
pick 310154e updated README formatting and added blame
pick a5f4a0d added cat-file
# Rebase 710f0f8..a5f4a0d onto 710f0f8
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
19
#DevoxxFR
Workflows
20
#DevoxxFR
Feature merge
21
#DevoxxFR
git-flow
22
#DevoxxFR
branche unique
23
#DevoxxFR
GitHub style
24
#DevoxxFR 25
La branche est-elle
terminée ?
Intégrer une branche
durable ?
git merge --no-ff
Intégrer les changements
d'une branche durable ?
L'historique a été revue ?
non oui
git merge
Est-ce une branche durable ?
oui
non
git pull --rebase=preserve
git add
git commit
non
oui
non
non
oui
git rebase -i
oui
#DevoxxFR
Merci !
@thebignet
slideshare.net/JeanDetoeuf
thebignet.github.io/talk-merge-rebase
26
Attribution 4.0 International

Git merge-rebase