Slide 1

Slide 1 text

Git - beyond commit keep your history clean Yannick Baron @yannick_baron Software Architecture Consultant

Slide 2

Slide 2 text

"Git is easy"

Slide 3

Slide 3 text

Clone the repository "Git is easy"

Slide 4

Slide 4 text

Clone the repository Make changes "Git is easy"

Slide 5

Slide 5 text

Clone the repository Make changes Mess things up "Git is easy"

Slide 6

Slide 6 text

Clone the repository Make changes Mess things up Look at StackOver fl ow and copy an obscure command "Git is easy"

Slide 7

Slide 7 text

Clone the repository Make changes Mess things up Look at StackOver fl ow and copy an obscure command Mess things up even more "Git is easy"

Slide 8

Slide 8 text

Clone the repository Make changes Mess things up Look at StackOver fl ow and copy an obscure command Mess things up even more Delete folder "Git is easy"

Slide 9

Slide 9 text

Clone the repository Make changes Mess things up Look at StackOver fl ow and copy an obscure command Mess things up even more Delete folder Clone the repository ... "Git is easy"

Slide 10

Slide 10 text

https://stackover fl ow.com/questions?tab=Votes

Slide 11

Slide 11 text

https://stackover fl ow.com/questions?tab=Votes

Slide 12

Slide 12 text

The core of git

Slide 13

Slide 13 text

• The git history is a graph, a tree to be precise • A node in that tree is the state of our fi les at a point in time • Most operations deal with how to navigate and manipulate that tree The git history

Slide 14

Slide 14 text

Tree Interlude?

Slide 15

Slide 15 text

• Understand the evolution of the project (history, communication) • Rollback to (or revert / redo) previous change • Find or compare to previously working code • Find which change introduced an error • Understand when development paths divert and see potential con fl ict • ... Uses of the git history

Slide 16

Slide 16 text

• Understand the evolution of the project (history, communication) • Rollback to (or revert / redo) previous change • Find or compare to previously working code • Find which change introduced an error • Understand when development paths divert and see potential con fl ict • ... A clean history keeps things readable, traceable and makes integration of changes easier Uses of the git history

Slide 17

Slide 17 text

Chaos vs Unity

Slide 18

Slide 18 text

Embrace Rebase

Slide 19

Slide 19 text

main feat feat main Simple Merge

Slide 20

Slide 20 text

main feat feat main feat main Late Merge

Slide 21

Slide 21 text

main feat main feat Control Merge main feat

Slide 22

Slide 22 text

main feat main feat Control Merge feat main feat2

Slide 23

Slide 23 text

main feat main feat main feat Rebase

Slide 24

Slide 24 text

Why do control merges happen?

Slide 25

Slide 25 text

But rebase is evil because force push is evil and loses data

Slide 26

Slide 26 text

BuT rEbAsE iS eViL bEcAuSe fOrCe pUsH iS eViL aNd LoSeS dAtA

Slide 27

Slide 27 text

But rebase is evil because force push is evil and loses data git push --force-with-lease git push --force-if-includes

Slide 28

Slide 28 text

git add -p git commit --amend [--no-edit] git commit --fixup 
 git rebase -i --autosquash Tricks to keep the history clean

Slide 29

Slide 29 text

Interactive Rebase

Slide 30

Slide 30 text

• fi xup • squash • reordering • editing past commits • rewording • ... Interactive Rebase

Slide 31

Slide 31 text

It's a wrap! • [email protected] 
 • https://www.thinktecture.com/thinktects/yannick-baron

Slide 32

Slide 32 text

git bisect start git bisect bad git bisect good [] Bonus: Bisect

Slide 33

Slide 33 text

git worktree add [] git worktree list git worktree remove Bonus: Worktrees