SlideShare a Scribd company logo
1 of 63
Download to read offline
Keep your GIT history
clean
Tomasz Brodziński
@TomaszBro
meaningless messages
“fixing bug”, “minor changes”, “clean up”, “oops”
repeated messages
“fix bug 9876”
“fix bug 9876”
“fix bug 9876”
tickets numbers only
“BUG-1234”
duplicating the code
“add property `foo`”
too long messages
“It is the big and important commit, which introduces
new functionality to our great application.”
too big commits
Commit message – formating and limitations
First line as summary of changes
● max 50 characters
First line as summary of changes
● max 50 characters
● begin with a capital letter
First line as summary of changes
● max 50 characters
● begin with a capital letter
● no period at the end
First line as summary of changes
● max 50 characters
● begin with a capital letter
● no period at the end
● imperative mood
Detailed description
● empty line
Detailed description
● empty line
● “what”, “why” not “how”
Detailed description
● empty line
● “what”, “why” not “how”
● wrap at 72 characters
Detailed description
● empty line
● “what”, “why” not “how”
● wrap at 72 characters
● markup syntax
Examples of good git repositories
● Git (https://github.com/git/git/commits/master)
● Linux kernel (https://github.com/torvalds/linux/commits/master)
● Spring Boot
(https://github.com/spring-projects/spring-boot/commits/master)
> git commit --amend
Modifying last commit
Undo last commits
> git reset HEAD~1
Undo last commits
> git reset HEAD~1
Undo last commits
> git reset HEAD~1
> git reset --hard HEAD~1
Undo commit
> git revert <commit>
Undo commit
> git revert <commit>
Three-way merge
C1 C5C2
C3 C4
C6
feature
master
Three-way merge
C1 C5C2
C3 C4
C6
feature
C7
master
Rebasing
C1 C5C2
master
C3 C4
C6
feature
Rebasing
C1 C5C2
master
C6
> git rebase master
C3' C4'
feature
C3 C4
feature
Rebasing
C1 C5C2
master
C6
> git rebase master
C3' C4'
feature
C3 C4
feature
Interactive rebasing
> git rebase -i HEAD~5
Interactive rebasing
modifying commit message
pick a2936e8 commit 1
reword 8f6e450 commit 2
pick dabb0ef commit 3
pick ef5a182 commit 4
pick 4df80af commit 5
Interactive rebasing
editing commit
pick a2936e8 commit 1
pick 4ef5850 new message
edit dabb0ef commit 3
pick ef5a182 commit 4
pick 4df80af commit 5
Rebasing
> git rebase --skip
> git rebase --continue
> git rebase --abort
Interactive rebasing
removing commit
pick a2936e8 commit 1
pick 4ef5850 new message
pick dabb0ef commit 3
pick ef5a182 commit 4
pick 4df80af commit 5
Interactive rebasing
removing commit
pick a2936e8 commit 1
pick 4ef5850 new message
pick dabb0ef commit 3
pick 4df80af commit 5
Interactive rebasing
squash commits
pick a2936e8 commit 1
pick 4ef5850 new message
squash a733bfe edited commit
pick 4df80af commit 5
Interactive rebasing
fixup commit
pick a2936e8 commit 1
pick e95fadc squashed commit
pick 4df80af commit 5
fixup 865ef03 commit 6
pick 4ee98c2 commit 7
Interactive rebasing
fixup commit
pick a2936e8 commit 1
fixup 865ef03 commit 6
pick e95fadc squashed commit
pick 4df80af commit 5
pick 4ee98c2 commit 7
Interactive rebasing
running shell command
pick 37ef6a3 commit 1
pick e95fadc squashed commit
exec make test
pick 4df80af commit 5
exec cd subdir; make test
pick 4ee98c2 commit 7
Fixup commit
> git commit --fixup=4df80af
Fixup commit
> git rebase -i --autosquash HEAD~5
pick a2936e8 commit 1
pick e95fadc squashed commit
pick 4df80af commit 5
fixup 723de73 fixup! commit 5
pick 4ee98c2 commit 7
Squash commit
> git commit --squash=a2936e8
Squash commit
> git rebase -i --autosquash HEAD~5
pick a2936e8 commit 1
squash 723de73 squash! commit 1
pick e95fadc squashed commit
pick 4df80af commit 5
pick 4ee98c2 commit 7
Reflog
> git reflog
8a8fa91 HEAD@{0}: merge branch1: Merge made by the
'recursive' strategy.
ddae7c1 HEAD@{1}: checkout: moving from branch1 to master
50465c0 HEAD@{2}: commit: Commit 4
ddae7c1 HEAD@{3}: commit: Commit 3
f15e834 HEAD@{4}: commit: My commit 2
4df80af HEAD@{5}: checkout: moving from master to branch1
4df80af HEAD@{6}: commit (initial): My first commit
Reflog
> git reset --hard HEAD@{3}
IDE vs terminal
Git log - filtering
> git log <origin>..<branch>
Git log - filtering
> git log --grep <search>
> git log <origin>..<branch>
Git log - filtering
> git log --grep <search>
> git log --before <date>
> git log <origin>..<branch>
Git log - filtering
> git log --grep <search>
> git log --before <date>
> git log --after <date>
> git log <origin>..<branch>
Git log - filtering
> git log --grep <search>
> git log --before <date>
> git log --after <date>
> git log --author <author name>
> git log <origin>..<branch>
Git log - formating
> git log
Git log - formating
> git log
> git log --oneline
Git log - formating
> git log
> git log --oneline
> git log --graph
Git log - formating
> git log
> git log --oneline
> git log --graph
> git log --decorate
Git log - formating
> git log
> git log --oneline
> git log --graph
> git log --decorate
> git log --oneline --graph --decorate
Thank you!

More Related Content

Similar to Keep your GIT history clean with well-formatted commit messages

Keep your GIT history clean
Keep your GIT history cleanKeep your GIT history clean
Keep your GIT history cleantomasbro
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017Katie Sylor-Miller
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Codemotion
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
Understanding git
Understanding gitUnderstanding git
Understanding gitAvik Das
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android DeveloperEffective
 
Version Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopVersion Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopAll Things Open
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 
Git for beginner
Git for beginnerGit for beginner
Git for beginnerTrung Huynh
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)Carlos Duarte do Nascimento
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUGMatthew McCullough
 

Similar to Keep your GIT history clean with well-formatted commit messages (20)

Keep your GIT history clean
Keep your GIT history cleanKeep your GIT history clean
Keep your GIT history clean
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Understanding git
Understanding gitUnderstanding git
Understanding git
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android Developer
 
Version Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopVersion Control and Git - GitHub Workshop
Version Control and Git - GitHub Workshop
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Git For Beginer
Git For BeginerGit For Beginer
Git For Beginer
 
Git for beginner
Git for beginnerGit for beginner
Git for beginner
 
Gittalk
GittalkGittalk
Gittalk
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)
 
Git
GitGit
Git
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUG
 
Git rebase
Git rebaseGit rebase
Git rebase
 

Recently uploaded

IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 

Recently uploaded (11)

IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 

Keep your GIT history clean with well-formatted commit messages