SlideShare a Scribd company logo
THAMARA HESSEL
I’m coder
GIT
Best Practices
3
Contents
▪ Commit - Best Practices
– The golden rules
– Good full example
▪ Rebase
– Rebase Interactive
▪ Merge
Commit
5
Commit - Best Practices
A project long term success should depend on the
way the “project log” is maintained.
It’s up to the users of the project to be the
maintainers. It’s easy to be sidetracked and forget
about doing the right thing, but it’s always better to
be respectful of your own work. You never
know when you will have to consult it later.
bugfix minor changes wtf
BUG-9284
more work Work on feature GRE-3958
Fix
Change X constant to be 10
Fix
oopsie
6
The golden rules
1. Separate subject from body with a blank line
2. Limit the subject line to 50 characters
3. Capitalize the subject line
4. Use the imperative mood in the subject line
5. Wrap the body at 72 characters
6. Use the body to explain what and why vs. how
7
1 - Separate subject from body with a blank line
git commit --help
Though not required, it’s a good idea to begin the commit message with a single short
(less than 50 character) line summarizing the change, followed by a blank line and then a more
thorough description
Sometimes there’s no need for a body in a commit, but only when the line you wrote is already specific
enough
For example:
➔ Fix typo in price list page
➔ Correct facebook redirect due to wrong token
8
2 - Limit the subject line to 50 characters
It’s not a hard limit per say, but should be an indicator.
Most of the tools when parsing the “Subject” of the commit limit it to 50 characters like mentioned
on the git commit manpage
Why?
Because if you’re writing more than that probably what you’re trying to do shouldn’t be in a single
commit.
Also a good indicator is if you put the word “and” on your subject.
9
3 - Capitalize the subject line
Begin all lines with a Capital letter
You’re starting a “Composition” you should never start it with a lowercase.
10
4 - Use the imperative mood in the subject line
Spoken or written as if giving a command or instruction
Update - Change - Add - Remove - Improve - Include - Implement - Fix … something
Git itself uses the imperative command when you do certain commands you can notice this:
➔ Merge branch ‘x’
➔ Revert "Wrong commit made"
➔ Merge pull request #123 from someuser/somebranch
11
4 - Use the imperative mood in the subject line - CONTINUE
For example
If applied, this commit will:
➔ refactor subsystem X for readability
➔ update getting started documentation
➔ remove deprecated methods
Notice how this doesn’t work for the other non-imperative forms. If applied, this commit will:
➔ fixed bug with Y
➔ changing behavior of X
➔ more fixes for broken stuff
➔ sweet new API methods
12
5 - Wrap the body at 72 characters
You should do 72 characters the same reason you do in the code to be easier to read.
Most log tools or viewing tools hard limit to 80 characters so with 72 and spaces you get
to that limit.
13
6 - Use the body to explain what and why vs. how
For me the most important thing!
Please always explain what and why you did, what you did and not how you did it!
Because if your commit is concise enough, I don’t need to go and see your code from top to bottom
just to understand why you did what you did.
14
Good full example
❏ 50 characters
❏ Capitalize
❏ A blank line
❏ Imperative mood
❏ 72 characters
❏ Body to explain what and why vs. how
Rebase
16
Rebase
Why rebase? To maintain a clean log.
There’s no point to create useless merge commits when all you’re doing is updating your branch with the
one you want to merge unto later.
So a simple rule of thumb is to rebase with the target branch and rebase often. Everyday you’re working you
should rebase your branch into your target branch and one last target before merging into it.
17
Rebase Interactive
When you’re working on a feature, you should always commit often it’s a good practice. But when
you’re finished, you should always squash it into a single commit.
after . . .
18
Rebase Interactive - continued
Possible commands:
➔ p, pick
➔ r, reword
➔ e, edit
➔ s, squash
➔ f, fixup
➔ x, exec
➔ d,drop
Merge
20
Merge
Merge is a great operation but it should be used correctly.
Please don’t merge directly into a feature branch from develop or master. Use rebase for it.
Merge is supposed to tell a story. It’s great when you want to make a release or a hotfix. In that way you
can identify exactly what you released by tagging the merge commit with a version
If you are consistently merging your “developing” code with a stable branch, it’s gonna do more harm
than good.
END (Q&A)
22

More Related Content

PPTX
Threshold Billing Script Without Video
Mary Clemons
 
PDF
No code stewardship - No Code Conf 2019 Demo Theater
Webflow
 
PDF
The View - Lotusscript coding best practices
Bill Buchan
 
PPTX
30% faster coder on-boarding when you have a code cookbook
Gabriel Paunescu 🤖
 
DOCX
Csc 440 assignment 2 convex hull out tuesday, feb 9th
RAJU852744
 
PPTX
CODE TUNINGtertertertrtryryryryrtytrytrtry
kapib57390
 
KEY
How we git - commit policy and code review
Ruben Tan
 
PDF
The View - The top 30 Development tips
Bill Buchan
 
Threshold Billing Script Without Video
Mary Clemons
 
No code stewardship - No Code Conf 2019 Demo Theater
Webflow
 
The View - Lotusscript coding best practices
Bill Buchan
 
30% faster coder on-boarding when you have a code cookbook
Gabriel Paunescu 🤖
 
Csc 440 assignment 2 convex hull out tuesday, feb 9th
RAJU852744
 
CODE TUNINGtertertertrtryryryryrtytrytrtry
kapib57390
 
How we git - commit policy and code review
Ruben Tan
 
The View - The top 30 Development tips
Bill Buchan
 

Similar to Git style best practices - OLX (20)

PPTX
Software development best practices & coding guidelines
Ankur Goyal
 
PDF
Maintainable Javascript carsonified
Christian Heilmann
 
PDF
Best Practices in Software Development
André Pitombeira
 
PDF
Femmengeeniring_Kateryna Mishchenko.pdf
ssuserc16f90
 
PDF
Good Coding Practices with JavaScript
🏁 Pierre-Henry Soria 💡
 
PDF
The View - 30 proven Lotuscript tips
Bill Buchan
 
PDF
Being dangerous with git
Gediminas Morkevicius
 
PDF
Dev buchan 30 proven tips
Bill Buchan
 
PPT
Siebel best practices
Satish Vemula
 
PPTX
C# coding standards, good programming principles & refactoring
Eyob Lube
 
PDF
Working with others using git and Github
Jacob Jenkins
 
PDF
YAGNI Principle and Clean Code
Luan Reffatti
 
PDF
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
PDF
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
Ortus Solutions, Corp
 
PDF
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
Gavin Pickin
 
PPTX
CPP03 - Repetition
Michael Heron
 
PDF
Creating Stable Assignments
Kevlin Henney
 
PPTX
Principled And Clean Coding
Metin Ogurlu
 
PDF
Put to the Test
Kevlin Henney
 
PPTX
Refactoring in Software Reengineering .pptx
itstehreem2830
 
Software development best practices & coding guidelines
Ankur Goyal
 
Maintainable Javascript carsonified
Christian Heilmann
 
Best Practices in Software Development
André Pitombeira
 
Femmengeeniring_Kateryna Mishchenko.pdf
ssuserc16f90
 
Good Coding Practices with JavaScript
🏁 Pierre-Henry Soria 💡
 
The View - 30 proven Lotuscript tips
Bill Buchan
 
Being dangerous with git
Gediminas Morkevicius
 
Dev buchan 30 proven tips
Bill Buchan
 
Siebel best practices
Satish Vemula
 
C# coding standards, good programming principles & refactoring
Eyob Lube
 
Working with others using git and Github
Jacob Jenkins
 
YAGNI Principle and Clean Code
Luan Reffatti
 
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
Ortus Solutions, Corp
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
Gavin Pickin
 
CPP03 - Repetition
Michael Heron
 
Creating Stable Assignments
Kevlin Henney
 
Principled And Clean Coding
Metin Ogurlu
 
Put to the Test
Kevlin Henney
 
Refactoring in Software Reengineering .pptx
itstehreem2830
 
Ad

More from Thamara Hessel (9)

PPTX
Liderar e ser liderado(a) - o que você precisa saber sobre liderança técnica
Thamara Hessel
 
PDF
What do software engineers do
Thamara Hessel
 
PDF
Arquitetura e qualidade de codigo
Thamara Hessel
 
PDF
Composer - tricks and tips
Thamara Hessel
 
PPTX
Code review Effective - kwan
Thamara Hessel
 
PPTX
Object calisthenics
Thamara Hessel
 
PDF
Git - Saia do Básico!
Thamara Hessel
 
PPTX
Qualidade de código
Thamara Hessel
 
PPTX
Refactoring sem complicação!
Thamara Hessel
 
Liderar e ser liderado(a) - o que você precisa saber sobre liderança técnica
Thamara Hessel
 
What do software engineers do
Thamara Hessel
 
Arquitetura e qualidade de codigo
Thamara Hessel
 
Composer - tricks and tips
Thamara Hessel
 
Code review Effective - kwan
Thamara Hessel
 
Object calisthenics
Thamara Hessel
 
Git - Saia do Básico!
Thamara Hessel
 
Qualidade de código
Thamara Hessel
 
Refactoring sem complicação!
Thamara Hessel
 
Ad

Recently uploaded (20)

PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 

Git style best practices - OLX

  • 3. 3 Contents ▪ Commit - Best Practices – The golden rules – Good full example ▪ Rebase – Rebase Interactive ▪ Merge
  • 5. 5 Commit - Best Practices A project long term success should depend on the way the “project log” is maintained. It’s up to the users of the project to be the maintainers. It’s easy to be sidetracked and forget about doing the right thing, but it’s always better to be respectful of your own work. You never know when you will have to consult it later. bugfix minor changes wtf BUG-9284 more work Work on feature GRE-3958 Fix Change X constant to be 10 Fix oopsie
  • 6. 6 The golden rules 1. Separate subject from body with a blank line 2. Limit the subject line to 50 characters 3. Capitalize the subject line 4. Use the imperative mood in the subject line 5. Wrap the body at 72 characters 6. Use the body to explain what and why vs. how
  • 7. 7 1 - Separate subject from body with a blank line git commit --help Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description Sometimes there’s no need for a body in a commit, but only when the line you wrote is already specific enough For example: ➔ Fix typo in price list page ➔ Correct facebook redirect due to wrong token
  • 8. 8 2 - Limit the subject line to 50 characters It’s not a hard limit per say, but should be an indicator. Most of the tools when parsing the “Subject” of the commit limit it to 50 characters like mentioned on the git commit manpage Why? Because if you’re writing more than that probably what you’re trying to do shouldn’t be in a single commit. Also a good indicator is if you put the word “and” on your subject.
  • 9. 9 3 - Capitalize the subject line Begin all lines with a Capital letter You’re starting a “Composition” you should never start it with a lowercase.
  • 10. 10 4 - Use the imperative mood in the subject line Spoken or written as if giving a command or instruction Update - Change - Add - Remove - Improve - Include - Implement - Fix … something Git itself uses the imperative command when you do certain commands you can notice this: ➔ Merge branch ‘x’ ➔ Revert "Wrong commit made" ➔ Merge pull request #123 from someuser/somebranch
  • 11. 11 4 - Use the imperative mood in the subject line - CONTINUE For example If applied, this commit will: ➔ refactor subsystem X for readability ➔ update getting started documentation ➔ remove deprecated methods Notice how this doesn’t work for the other non-imperative forms. If applied, this commit will: ➔ fixed bug with Y ➔ changing behavior of X ➔ more fixes for broken stuff ➔ sweet new API methods
  • 12. 12 5 - Wrap the body at 72 characters You should do 72 characters the same reason you do in the code to be easier to read. Most log tools or viewing tools hard limit to 80 characters so with 72 and spaces you get to that limit.
  • 13. 13 6 - Use the body to explain what and why vs. how For me the most important thing! Please always explain what and why you did, what you did and not how you did it! Because if your commit is concise enough, I don’t need to go and see your code from top to bottom just to understand why you did what you did.
  • 14. 14 Good full example ❏ 50 characters ❏ Capitalize ❏ A blank line ❏ Imperative mood ❏ 72 characters ❏ Body to explain what and why vs. how
  • 16. 16 Rebase Why rebase? To maintain a clean log. There’s no point to create useless merge commits when all you’re doing is updating your branch with the one you want to merge unto later. So a simple rule of thumb is to rebase with the target branch and rebase often. Everyday you’re working you should rebase your branch into your target branch and one last target before merging into it.
  • 17. 17 Rebase Interactive When you’re working on a feature, you should always commit often it’s a good practice. But when you’re finished, you should always squash it into a single commit. after . . .
  • 18. 18 Rebase Interactive - continued Possible commands: ➔ p, pick ➔ r, reword ➔ e, edit ➔ s, squash ➔ f, fixup ➔ x, exec ➔ d,drop
  • 19. Merge
  • 20. 20 Merge Merge is a great operation but it should be used correctly. Please don’t merge directly into a feature branch from develop or master. Use rebase for it. Merge is supposed to tell a story. It’s great when you want to make a release or a hotfix. In that way you can identify exactly what you released by tagging the merge commit with a version If you are consistently merging your “developing” code with a stable branch, it’s gonna do more harm than good.
  • 22. 22