SlideShare a Scribd company logo
1 of 38
Download to read offline
HOGENT 14/04/16
WIE BEN IK?
BIO
▸Thomas Nys
▸1986
▸Hamme /
Gent
WIE BEN IK?
PROFESSIONEEL
▸Ruby On Rails
▸Rialto
(PropTech
startup)
WIE BEN IK?
HOBBYS
▸Lezen
▸Ruby Belgium
▸Crossfit
▸Elixir
WIE BEN IK?
OVERZICHT
▸ Git history
▸ Git basics
▸ Commit messages
▸ Merge vs rebase
▸ Merge conflicts
▸ Workflow
▸ Git voodoo
▸ Git resources
GIT HISTORY
I'M DOING A (FREE) OPERATING SYSTEM
(JUST A HOBBY, WON'T BE BIG AND
PROFESSIONAL LIKE GNU) FOR 386(486)
AT CLONES.
Linus Torvalds, 25-08-1991
GIT HISTORY
LINUS TORVALDS
▸Finse programmeur
▸Vader linux-kernel
▸Ontevreden met
CVS
GIT HISTORY
NODEN
▸Performant
▸Gedistribueerd
▸Fout-tolerant
GIT HISTORY
BITKEEPER
▸ Gratis voor Linux-maintainers (niet opensource)
▸ Iemand probeert Bitkeeper te reverse
engineeren
▸ Bitkeeper stopt met Linux te steunen
▸ April 2005 gestart met eerste versie git
GIT HISTORY
GIT BASICS
SNAPSHOTS GEEN DELTAS
▸ Andere VCS’en
== delta’s van
een bepaalde
basefile
▸ Git == stream van
snapshots
GIT BASICS
ALLES LOKAAL
▸Gedistribueerd model
▸Snelheid!
▸Offline werken
GIT BASICS
GIT == DATA-INTEGRITEIT
▸ Alles in git gechecksummed met SHA-1
hash naar een hexadecimale string van 40
karakters
▸ Elke wijziging opspoorbaar
▸ Alles is omkeerbaar
GIT BASICS
3 STADIA
▸ Modified
▸ Gewijzigd maar niet opgeslagen
▸ Staged
▸ Klaargezet om te committen
▸ Cmmitted
▸ “Opgeslagen”
GIT BASICS
BRANCHING
▸Branch is een snapshot van de situatie
op het moment waar de branch
afgetakt is
▸Branch is letterlijk een aftakking
▸Je kan branchen op een branch
GIT BASICS
.GITIGNORE
▸ File met te negeren bestanden
▸ Typisch voor bestanden met gevoelige informatie of
tijdelijke bestanden
▸ Repo basis: vb file met database-wachtwoorden
▸ Globaal hele systeem: vb. tmp-files typisch voor het OS
GIT BASICS
DEMO
GIT BASICS
COMMIT
MESSAGES
7 REGELS VOOR EEN GOEDE COMMIT MESSAGE
1. Hou onderwerp en body gescheiden met 1 witregel
2. Beperk de lengte van het onderwerp tot 50 karakters
3. Het onderwerp begint met een hoofdletter
4. Gebruik geen punt op het einde van het onderwerp
5. Gebruik de gebiedende wijs in het onderwerp
6. Beperk de breedte van de body to 72 karakters
7. Geef in je body een uitleg voor wat en waarom, niet over hoe
COMMIT MESSAGES
MEER OVER COMMIT MESSAGES
▸ Een rant van Linus Torvalds over commit-messages:
▸ https://github.com/torvalds/linux/pull/
17#issuecomment-5659933
▸ Blogpost die dieper ingaat op deze 7 regels:
▸ http://chris.beams.io/posts/git-commit/
COMMIT MESSAGES
MERGE VS
REBASE
MERGE
▸ Makkelijkst
▸ Laat de geschiedenis as
is
▸ Extra commit iedere
keer changes van master
worden gemerged
▸ Geeft een heel slordige
git-history
▸ Minder geschikt voor
team-werk
MERGE VS REBASE
REBASE
▸ Iets geavanceerder
▸ Geen overbodige
merge-commits
▸ Mooie lineaire
geschiedenis
▸ Geschiedenis
herschreven, niet
gebruiker op publieke
branches
MERGE VS REBASE
MERGE
CONFLICTS
WANNEER?
▸ Wanneer eenzelfde lijn in eenzelfde bestand is aangepast
in 2 branches.
▸ Wanneer een file in 1 branch verwijderd is maar in een
andere gewijzigd.
MERGE CONFLICTS
DEMO
MERGE CONFLICTS
WORKFLOW
(in kleine teams)
GITHUB
▸ Marktleider hosting git-repo’s
▸ Meeste open-source projecten zitten op git
GITLAB
▸ Evenwaardig maar kleiner
▸ Snelle progressie
▸ Kan sneller groeien door te leren uit fouten github
WORKFLOW
BASICS
▸ Master == productie-code
▸ Nooit pushen naar master !!!
▸ Iedereen branched op master
▸ Indien feature:
▸ branchnaam: feature/coole-feature
▸ Indien bug:
▸ branchnaam: bug/het-is-kapot
WORKFLOW
CODE TERUG NAAR MASTER
▸ Indien de feature/bug klaar —> PR op Github
▸ Rebasen met master (changes in master naar branch brengen)
▸ Wordt toegewezen aan iemand van het team en nagekeken
▸ Code review is een leerrijk proces en geen ego-kwestie
▸ Jij bent je code niet
▸ Stijl en syntax automatisch laten checken (voorkomt al heel wat ego-zaken)
▸ Zorg voor een ci die automatisch testen loopt en zo al een eerste vorm van
feedback geeft, testen falen == probleem
▸ Indien ok de pull-request gemerged en automatisch een deploy naar productie
WORKFLOW
DEMO
WORKFLOW
GIT VOODOO
▸ git rebase -i
▸ git fixup & autosquash
▸ git bisect
▸ git cherry-pick
▸ git add -patch
▸ git add -i
▸ git reflog
▸ tig
▸ git-extras
GIT VOODOO
GIT RESOURCES
▸ Officiële documentatie:
▸ https://git-scm.com/
▸ Podcast
▸ https://www.briefs.fm/git-tips
▸ Interactieve cheatsheet:
▸ http://ndpsoftware.com/git-cheatsheet.html
▸ Tutorial:
▸ https://www.atlassian.com/git/tutorials/
▸ Meer info over .git-folder
▸ https://medium.freecodecamp.com/understanding-git-for-real-by-
exploring-the-git-directory-1e079c15b807#.gmhespqdy
THX!
Nog vragen?
Twitter: @nysthee
Email: nysthee@gmail.com

More Related Content

Viewers also liked

Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...fureigh
 
A painless git workflow
A painless git workflowA painless git workflow
A painless git workflowrogthefrog
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositoriesMatt Aunger
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitCraig Smith
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?Leonid Mamchenkov
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlJeremy Coates
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesNed Potter
 

Viewers also liked (13)

Git
GitGit
Git
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...
 
GIT Fundamentals
GIT FundamentalsGIT Fundamentals
GIT Fundamentals
 
Git advanced
Git advancedGit advanced
Git advanced
 
A painless git workflow
A painless git workflowA painless git workflow
A painless git workflow
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositories
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
 

Git Hogent