SlideShare a Scribd company logo
1 of 37
Download to read offline
Keep your GIT history
clean
Tomasz Brodziński
@TomaszBro
Commit message – formating and limitations
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
● “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 <commit>
> git reset --hard <commit>
Undo commit
> git revert <commit>
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
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
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 --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 --oneline
> git log --graph
> git log --decorate
> git log --oneline --graph --decorate
Thank you!

More Related Content

What's hot

Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Mizan Riqzia
 
Python code for servo control using Raspberry Pi
Python code for servo control using Raspberry PiPython code for servo control using Raspberry Pi
Python code for servo control using Raspberry PiAmarjeetsingh Thakur
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning InfrastructurePerforce
 
Python_Session
Python_SessionPython_Session
Python_Sessionsiva ram
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介Wen Liao
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
unix crontab basics
unix crontab basicsunix crontab basics
unix crontab basicssaratsandhya
 

What's hot (9)

Git社内勉強会
Git社内勉強会Git社内勉強会
Git社内勉強会
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
Python code for servo control using Raspberry Pi
Python code for servo control using Raspberry PiPython code for servo control using Raspberry Pi
Python code for servo control using Raspberry Pi
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure
 
Python_Session
Python_SessionPython_Session
Python_Session
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
unix crontab basics
unix crontab basicsunix crontab basics
unix crontab basics
 

Similar to Keep your GIT history clean

Keep you GIT history clean
Keep you GIT history cleanKeep you GIT history clean
Keep you GIT history cleantomasbro
 
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
 
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 Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 
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 Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitRasan Samarasinghe
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With GitHoffman Lab
 
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
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Git Introduction with illustrations
Git Introduction with illustrationsGit Introduction with illustrations
Git Introduction with illustrationsThao Huynh Quang
 

Similar to Keep your GIT history clean (20)

Keep you GIT history clean
Keep you GIT history cleanKeep you GIT history clean
Keep you GIT history clean
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
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
 
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
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Git
GitGit
Git
 
Version Control and Git - GitHub Workshop
Version Control and Git - GitHub WorkshopVersion Control and Git - GitHub Workshop
Version Control and Git - GitHub Workshop
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
M.Mozūras - git
M.Mozūras - gitM.Mozūras - git
M.Mozūras - git
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
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
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Git Introduction with illustrations
Git Introduction with illustrationsGit Introduction with illustrations
Git Introduction with illustrations
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Keep your GIT history clean