SlideShare a Scribd company logo
Git best practices
AKA
Let's write history
Git / t/ɡɪ
”A silly,incompetent,stupid,
annoying or childish person.”
http://en.wiktionary.org/wiki/git
"I'm an egotistical bastard,so I
name all my projects after myself.
First Linux,now Git”
Linus Torvalds,PC World.2012-07-14
Git popularity according to OpenHub.net
Git popularity according to Google Trends
git
svn
Why do we use git and version control at all?
Because history matters.In societies,and in software
projects too.History teaches where we came from and
where we are going.
Software is built patch by patch
When a patch is committed to version control,it becomes
a permanent part of history.
Understanding the nature of a patch is required to make
good git commits.
A patch
-attributes the author
-has a title
-may have a message
-describes the lines added,removed and modified
-the change is complete and self standing
-e.g.fixes a defect or extends functionality
You must master reading history before you can master
writing it.If you think you can master writing history
directly,you did not understand the nature of history at
all.
Browsing GitHub,Gitlab,git-web et cetera is good,but
inspecting your local copy directly is best.
git log --oneline
git show e413c6e
gitk --all
gitk --all
Note the existing style.You need to write in the same
language to be understood.
Some universal rules apply,though.
Universal git commit rules:
-Start the title line with a capital letter just like in email
-Don't end with a dot
-Keep title under 72 characters (the Github limit)
-Title is followed by one empty line,and then comes the
description
-The message part contains full sentences with ending
dots etc
-Use imperative format (Not 'Cleaned'but 'Clean up')
Commit titles must look good in'git log --oneline'
and
complete the sentence'This change will..'
Focus on describing WHY the change was made.
The revision history diff will always show WHAT was
changed.If your code is reviewed,the reviewer will focus
on judging the rationale of the WHY and compare it to
the WHAT to verify that they match.
If it is later discovered that your code had a bug,the
contents will be updated (WHAT) but the purpose of what
it does will remain (WHY).
The best and permanent place for code documentation is
in inline comments.Don't repeat inline comments in the
commit message.
The commit message should focus on why the change
was needed,while the inline comment documents the
current version of the code.
Is the change related to an issue or discussion available
somewhere else?
Include issue numbers and URLs in the commit message.
Use trigger words like "Closes #123"to enable Github to
make automatic links and update issues statuses.
Work-in-progress commits
Few people write the correct code in one go.Thus writing
the correct git commit right away might not be possible.
While developing,title the commits WIP,WIP2,WIP3 etc.
When you are done,rebase and squash the changes into
the final commits that constitute logical steps.
git rebase -i master
Other important tools to write history:
git cherry-pick e413c6e
git citool
git citool --amend
My favourite: git citool
You can also spend all day writing code and at the end of the day save
your work with 'git citool',where you can pick the hunks or lines that go
together to form the commits.
Are you committing somebody else's code?
Mark authorship correctly:
git commit -a --author "Dieter Adriaenssens <xxx@gmail.com>"
git commit --amend --author="James Cowgill <xxx@debian.org>"
git apply --author="Andreas Beckmann <xxx@debian.org>"/tmp/andreas.patch
Branches
A series of commits.The purpose of branches is to allow
different versions of the software to exists in parallel.
Typically there is a development master branch and a
relase branch v1,which can evolve in separate
directions.
The master branch may become release v2 while the v1
branch may become release v1.1.
All developers branch from
master and then merge back.
New releases branch
from master.
Support releases branch
from release branch.
Image source:
http://tleyden.github.io/blog/2014/04/09/a-suc
cessful-git-branching-model-with-enterprise-su
pport/
The holy master principle:
Never break the master branch!
All developers working to create new features or fix bugs
use the current master branch as the base of their work.
If the master is already broken,it will be difficult to fix
the bug the developer intended to spend time fixing,or a
new feature cannot be made to be functional if the
starting point wasn't functional either.
Git is a distributed version control system
Every copy of the repository is a branch in itself.To share
branches with others before they are merged to master,
label the branch with a separate name.
git checkout master
git pull master
git checkout -b feature-automatic-renewals
git citool
...
git push origin feature-automatic-renewals
Apply the changes made by a collaborator:
git pull http://people.debian.org/~sthibault/tmp/mariadb-10.0 feature-hurd
After this your feature-hurd branch will have the same
contents,and you can continue improving it.
Many prefer to publish and pull via GitHub,but any server
you can push files on with SSH and pull via SSH or HTTP
will do.
The holy QualityAssurance principle:
all commits on master should go via review
GitHub "Pull Requests"facilitate this.
Gerrit and Gerrithub for more formal teams.
Review principles:
-Give feedback,even nitty gritty,to perfection the code
(and documentation!).
-Let the submitter fix it themselves,thus keeping
authorship and commitment to maintaining the code.
-Reviewing as an opportunity to learn.Both for the
reviewee and reviewer!
Review stalls (often,unfortunately):
-Reviewer does not agree on the motivation to the
change
-Reviewer does not understand the contents of the
changes
-Poor documentation,unlogical commits
-Lack of QA,no testcases,no external verification
-Unfit change for the upcoming release,lack of time,
wrong reviewer
The holy history principle: never force push on master
Except if you are really quick and sure that nobody made
a git pull in between.
If the rule is broken,developers and systems will have
diverged versions of master,and everybody will need to
do manual merges or dangerous force pulls.
Remember: good outcomes require a lot of work
Don't feel frustrated.The devil is often in the details and
the nature of high quality code and reliable systems
require diligent review. All big stable systems grew our
of very small stable systems.
Do not sacrifice stability for development velocity,
otherwise it will just collect debt and require twice as
much work later and grind development velocity to a full
stop.
The hotfix principle
If you have blinking lights and sirens yelling,
you can and should do whatever you need to.
Beginner tips
Learn the basics: http://try.github.com/
SSH-keys:
https://help.github.com/articles/generating-ssh-keys/
Keep branch name visible in the bash prompt:
https://github.com/ottok/tooling/blob/master/bashrc/bashrc.git
Contact Seravo if you need experts in
Linux,Git or other
open source software
Open seravo.fi
See our blog for in-depth tips

More Related Content

What's hot (20)

PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
PDF
Intro to Git & GitHub
GoogleDevelopersStud
 
PPTX
Introduction to Git and GitHub Part 1
Omar Fathy
 
PDF
CI is dead, long live CI
Frédéric Lepied
 
PDF
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup
 
PPT
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
PDF
git and github
Darren Oakley
 
PPTX
GitHub Presentation
BrianSchilder
 
PDF
Introduction to Git and Github
Houari ZEGAI
 
PDF
Inside GitHub
err
 
PPTX
Intro to Git and GitHub
Uri Goldstein
 
PPTX
GitFlow, SourceTree and GitLab
Shinu Suresh
 
PPTX
A prentation on github
Veronica Ojochona Michael (MCP)
 
PPTX
Git and git workflow best practice
Majid Hosseini
 
PDF
Github - Git Training Slides: Foundations
Lee Hanxue
 
PDF
Git, GitHub and Open Source
Lorna Mitchell
 
PPTX
Git basics to advance with diagrams
Dilum Navanjana
 
PPTX
Github
piyush khadse
 
KEY
Introduction to Git
Lukas Fittl
 
PPTX
Introduction to git and Github
Wycliff1
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
Intro to Git & GitHub
GoogleDevelopersStud
 
Introduction to Git and GitHub Part 1
Omar Fathy
 
CI is dead, long live CI
Frédéric Lepied
 
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup
 
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
git and github
Darren Oakley
 
GitHub Presentation
BrianSchilder
 
Introduction to Git and Github
Houari ZEGAI
 
Inside GitHub
err
 
Intro to Git and GitHub
Uri Goldstein
 
GitFlow, SourceTree and GitLab
Shinu Suresh
 
A prentation on github
Veronica Ojochona Michael (MCP)
 
Git and git workflow best practice
Majid Hosseini
 
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git, GitHub and Open Source
Lorna Mitchell
 
Git basics to advance with diagrams
Dilum Navanjana
 
Introduction to Git
Lukas Fittl
 
Introduction to git and Github
Wycliff1
 

Viewers also liked (20)

PDF
WordPress security 101 - WP Turku Meetup 2.2.2017
Otto Kekäläinen
 
PDF
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
Otto Kekäläinen
 
PDF
Find WordPress performance bottlenecks with XDebug PHP profiling
Otto Kekäläinen
 
PDF
Visual Design with Data
Seth Familian
 
PPT
GIT guidelines
Mona Saleh Abd El Salam
 
PDF
Build Features, Not Apps
Natasha Murashev
 
PPTX
To Rebase or Not to Rebase: Taming Your Git History
Perforce
 
PDF
Keep you GIT history clean
tomasbro
 
PDF
Git essentials
Otto Kekäläinen
 
PDF
MariaDB Developers Meetup 2016 welcome words
Otto Kekäläinen
 
PDF
Collaboration in open source - examples from MariaDB
Otto Kekäläinen
 
PPTX
WordPress ja markkinointiautomaatio (DigitalTre-esitys)
Otto Kekäläinen
 
PDF
MariaDB in Debian and Ubuntu: The next million users
Otto Kekäläinen
 
PDF
Koodikerho PEPE Pajapäivä 6.9.2016
Otto Kekäläinen
 
PDF
Koodikerho: ohjelmointia alakouluissa
Otto Kekäläinen
 
PDF
MariaDB Foundation presentation and membership info
Otto Kekäläinen
 
PDF
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
Otto Kekäläinen
 
PDF
Testing and updating WordPress - Advanced techniques for avoiding regressions
Otto Kekäläinen
 
PDF
Less passwords, more security: unix socket authentication and other MariaDB h...
Otto Kekäläinen
 
PDF
Computer-free Website Development Demo - WordPressDC Jan 2015
Anthony D. Paul
 
WordPress security 101 - WP Turku Meetup 2.2.2017
Otto Kekäläinen
 
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
Otto Kekäläinen
 
Find WordPress performance bottlenecks with XDebug PHP profiling
Otto Kekäläinen
 
Visual Design with Data
Seth Familian
 
GIT guidelines
Mona Saleh Abd El Salam
 
Build Features, Not Apps
Natasha Murashev
 
To Rebase or Not to Rebase: Taming Your Git History
Perforce
 
Keep you GIT history clean
tomasbro
 
Git essentials
Otto Kekäläinen
 
MariaDB Developers Meetup 2016 welcome words
Otto Kekäläinen
 
Collaboration in open source - examples from MariaDB
Otto Kekäläinen
 
WordPress ja markkinointiautomaatio (DigitalTre-esitys)
Otto Kekäläinen
 
MariaDB in Debian and Ubuntu: The next million users
Otto Kekäläinen
 
Koodikerho PEPE Pajapäivä 6.9.2016
Otto Kekäläinen
 
Koodikerho: ohjelmointia alakouluissa
Otto Kekäläinen
 
MariaDB Foundation presentation and membership info
Otto Kekäläinen
 
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
Otto Kekäläinen
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Otto Kekäläinen
 
Less passwords, more security: unix socket authentication and other MariaDB h...
Otto Kekäläinen
 
Computer-free Website Development Demo - WordPressDC Jan 2015
Anthony D. Paul
 
Ad

Similar to Git best practices 2016 (20)

PPT
Introduction to Git for developers
Dmitry Guyvoronsky
 
PDF
Git_tutorial.pdf
AliaaTarek5
 
PPTX
Mini-training: Let’s Git It!
Betclic Everest Group Tech Team
 
PDF
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
VincitOy
 
PPTX
Git essential training & sharing self
Chen-Tien Tsai
 
ODP
Contributing to Upstream Open Source Projects
Scott Garman
 
PPTX
Workshop on Git and GitHub
DSCVSSUT
 
PDF
Git Tutorial
Ahmed Taha
 
PPTX
Introduction to git hub
Naveen Pandey
 
PDF
Git workshop
Reslan Al Tinawi
 
PPT
391Lecture0909 Vision control of git.ppt
GevitaChinnaiah
 
PDF
[2015/2016] Collaborative software development with Git
Ivano Malavolta
 
PDF
Git & Code review
Cenk Gültekin
 
PPTX
Migrating To GitHub
Sridhar Peddinti
 
PPTX
Git Session 2K23.pptx
Eshaan35
 
PPT
3 Git
Fabio Fumarola
 
PPT
Git
Alf Chang
 
PPTX
Git
Shinu Suresh
 
PPT
Git
zafarfaizi
 
PDF
A Git MVP Workflow
Burt Lum
 
Introduction to Git for developers
Dmitry Guyvoronsky
 
Git_tutorial.pdf
AliaaTarek5
 
Mini-training: Let’s Git It!
Betclic Everest Group Tech Team
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
VincitOy
 
Git essential training & sharing self
Chen-Tien Tsai
 
Contributing to Upstream Open Source Projects
Scott Garman
 
Workshop on Git and GitHub
DSCVSSUT
 
Git Tutorial
Ahmed Taha
 
Introduction to git hub
Naveen Pandey
 
Git workshop
Reslan Al Tinawi
 
391Lecture0909 Vision control of git.ppt
GevitaChinnaiah
 
[2015/2016] Collaborative software development with Git
Ivano Malavolta
 
Git & Code review
Cenk Gültekin
 
Migrating To GitHub
Sridhar Peddinti
 
Git Session 2K23.pptx
Eshaan35
 
A Git MVP Workflow
Burt Lum
 
Ad

More from Otto Kekäläinen (20)

PDF
FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
Otto Kekäläinen
 
PDF
Search in WordPress - how it works and howto customize it
Otto Kekäläinen
 
PDF
MariaDB quality assurance in Debian and Ubuntu
Otto Kekäläinen
 
PDF
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
Otto Kekäläinen
 
PDF
Technical SEO for WordPress - 2019 edition
Otto Kekäläinen
 
PDF
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Otto Kekäläinen
 
PDF
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
Otto Kekäläinen
 
PDF
DebConf 2019 MariaDB packaging in Debian BoF
Otto Kekäläinen
 
PDF
The 5 most common reasons for a slow WordPress site and how to fix them
Otto Kekäläinen
 
PDF
How to investigate and recover from a security breach in WordPress
Otto Kekäläinen
 
PDF
Technical SEO for WordPress
Otto Kekäläinen
 
PDF
Automatic testing and quality assurance for WordPress plugins and themes
Otto Kekäläinen
 
PDF
10 things every developer should know about their database to run word press ...
Otto Kekäläinen
 
PDF
Automatic testing and quality assurance for WordPress plugins
Otto Kekäläinen
 
PDF
Improving WordPress performance (xdebug and profiling)
Otto Kekäläinen
 
PDF
WordPress-tietoturvan perusteet
Otto Kekäläinen
 
PDF
Technical SEO for WordPress - 2017 edition
Otto Kekäläinen
 
PDF
Improving WordPress Performance with Xdebug and PHP Profiling
Otto Kekäläinen
 
PDF
MariaDB adoption in Linux distributions and development environments
Otto Kekäläinen
 
PDF
DebConf16 BoF on MariaDB/MySQL packaging
Otto Kekäläinen
 
FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
Otto Kekäläinen
 
Search in WordPress - how it works and howto customize it
Otto Kekäläinen
 
MariaDB quality assurance in Debian and Ubuntu
Otto Kekäläinen
 
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
Otto Kekäläinen
 
Technical SEO for WordPress - 2019 edition
Otto Kekäläinen
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Otto Kekäläinen
 
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
Otto Kekäläinen
 
DebConf 2019 MariaDB packaging in Debian BoF
Otto Kekäläinen
 
The 5 most common reasons for a slow WordPress site and how to fix them
Otto Kekäläinen
 
How to investigate and recover from a security breach in WordPress
Otto Kekäläinen
 
Technical SEO for WordPress
Otto Kekäläinen
 
Automatic testing and quality assurance for WordPress plugins and themes
Otto Kekäläinen
 
10 things every developer should know about their database to run word press ...
Otto Kekäläinen
 
Automatic testing and quality assurance for WordPress plugins
Otto Kekäläinen
 
Improving WordPress performance (xdebug and profiling)
Otto Kekäläinen
 
WordPress-tietoturvan perusteet
Otto Kekäläinen
 
Technical SEO for WordPress - 2017 edition
Otto Kekäläinen
 
Improving WordPress Performance with Xdebug and PHP Profiling
Otto Kekäläinen
 
MariaDB adoption in Linux distributions and development environments
Otto Kekäläinen
 
DebConf16 BoF on MariaDB/MySQL packaging
Otto Kekäläinen
 

Recently uploaded (20)

PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 

Git best practices 2016

  • 2. Git / t/ɡɪ ”A silly,incompetent,stupid, annoying or childish person.” http://en.wiktionary.org/wiki/git
  • 3. "I'm an egotistical bastard,so I name all my projects after myself. First Linux,now Git” Linus Torvalds,PC World.2012-07-14
  • 4. Git popularity according to OpenHub.net
  • 5. Git popularity according to Google Trends git svn
  • 6. Why do we use git and version control at all? Because history matters.In societies,and in software projects too.History teaches where we came from and where we are going.
  • 7. Software is built patch by patch
  • 8. When a patch is committed to version control,it becomes a permanent part of history. Understanding the nature of a patch is required to make good git commits.
  • 9. A patch -attributes the author -has a title -may have a message -describes the lines added,removed and modified -the change is complete and self standing -e.g.fixes a defect or extends functionality
  • 10. You must master reading history before you can master writing it.If you think you can master writing history directly,you did not understand the nature of history at all.
  • 11. Browsing GitHub,Gitlab,git-web et cetera is good,but inspecting your local copy directly is best.
  • 16. Note the existing style.You need to write in the same language to be understood. Some universal rules apply,though.
  • 17. Universal git commit rules: -Start the title line with a capital letter just like in email -Don't end with a dot -Keep title under 72 characters (the Github limit) -Title is followed by one empty line,and then comes the description -The message part contains full sentences with ending dots etc -Use imperative format (Not 'Cleaned'but 'Clean up')
  • 18. Commit titles must look good in'git log --oneline' and complete the sentence'This change will..'
  • 19. Focus on describing WHY the change was made. The revision history diff will always show WHAT was changed.If your code is reviewed,the reviewer will focus on judging the rationale of the WHY and compare it to the WHAT to verify that they match. If it is later discovered that your code had a bug,the contents will be updated (WHAT) but the purpose of what it does will remain (WHY).
  • 20. The best and permanent place for code documentation is in inline comments.Don't repeat inline comments in the commit message. The commit message should focus on why the change was needed,while the inline comment documents the current version of the code.
  • 21. Is the change related to an issue or discussion available somewhere else? Include issue numbers and URLs in the commit message. Use trigger words like "Closes #123"to enable Github to make automatic links and update issues statuses.
  • 22. Work-in-progress commits Few people write the correct code in one go.Thus writing the correct git commit right away might not be possible. While developing,title the commits WIP,WIP2,WIP3 etc. When you are done,rebase and squash the changes into the final commits that constitute logical steps. git rebase -i master
  • 23. Other important tools to write history: git cherry-pick e413c6e git citool git citool --amend
  • 24. My favourite: git citool You can also spend all day writing code and at the end of the day save your work with 'git citool',where you can pick the hunks or lines that go together to form the commits.
  • 25. Are you committing somebody else's code? Mark authorship correctly: git commit -a --author "Dieter Adriaenssens <[email protected]>" git commit --amend --author="James Cowgill <[email protected]>" git apply --author="Andreas Beckmann <[email protected]>"/tmp/andreas.patch
  • 26. Branches A series of commits.The purpose of branches is to allow different versions of the software to exists in parallel. Typically there is a development master branch and a relase branch v1,which can evolve in separate directions. The master branch may become release v2 while the v1 branch may become release v1.1.
  • 27. All developers branch from master and then merge back. New releases branch from master. Support releases branch from release branch. Image source: http://tleyden.github.io/blog/2014/04/09/a-suc cessful-git-branching-model-with-enterprise-su pport/
  • 28. The holy master principle: Never break the master branch! All developers working to create new features or fix bugs use the current master branch as the base of their work. If the master is already broken,it will be difficult to fix the bug the developer intended to spend time fixing,or a new feature cannot be made to be functional if the starting point wasn't functional either.
  • 29. Git is a distributed version control system Every copy of the repository is a branch in itself.To share branches with others before they are merged to master, label the branch with a separate name. git checkout master git pull master git checkout -b feature-automatic-renewals git citool ... git push origin feature-automatic-renewals
  • 30. Apply the changes made by a collaborator: git pull http://people.debian.org/~sthibault/tmp/mariadb-10.0 feature-hurd After this your feature-hurd branch will have the same contents,and you can continue improving it. Many prefer to publish and pull via GitHub,but any server you can push files on with SSH and pull via SSH or HTTP will do.
  • 31. The holy QualityAssurance principle: all commits on master should go via review GitHub "Pull Requests"facilitate this. Gerrit and Gerrithub for more formal teams.
  • 32. Review principles: -Give feedback,even nitty gritty,to perfection the code (and documentation!). -Let the submitter fix it themselves,thus keeping authorship and commitment to maintaining the code. -Reviewing as an opportunity to learn.Both for the reviewee and reviewer!
  • 33. Review stalls (often,unfortunately): -Reviewer does not agree on the motivation to the change -Reviewer does not understand the contents of the changes -Poor documentation,unlogical commits -Lack of QA,no testcases,no external verification -Unfit change for the upcoming release,lack of time, wrong reviewer
  • 34. The holy history principle: never force push on master Except if you are really quick and sure that nobody made a git pull in between. If the rule is broken,developers and systems will have diverged versions of master,and everybody will need to do manual merges or dangerous force pulls.
  • 35. Remember: good outcomes require a lot of work Don't feel frustrated.The devil is often in the details and the nature of high quality code and reliable systems require diligent review. All big stable systems grew our of very small stable systems. Do not sacrifice stability for development velocity, otherwise it will just collect debt and require twice as much work later and grind development velocity to a full stop.
  • 36. The hotfix principle If you have blinking lights and sirens yelling, you can and should do whatever you need to.
  • 37. Beginner tips Learn the basics: http://try.github.com/ SSH-keys: https://help.github.com/articles/generating-ssh-keys/ Keep branch name visible in the bash prompt: https://github.com/ottok/tooling/blob/master/bashrc/bashrc.git
  • 38. Contact Seravo if you need experts in Linux,Git or other open source software Open seravo.fi See our blog for in-depth tips