SlideShare a Scribd company logo
LEMi ORHAN ERGiN
agile software craftsman @ iyzico
GITANTI
PATTERNS
How To Mess Up With Git and Love It Again
/lemiorhan
lemiorhanergin.com
@lemiorhan
meetup.scturkey.org
agileturkey.org
dev.iyzipay.com
LEMi ORHAN ERGiN
agile software craftsman @ iyzico
agile practice lead at iyzico
developing software since 2001
worked at Sony, eBay/GittiGidiyor, ACM
consultant, architect, mentor, developer
founder of Software Craftsmanship Turkey
ex community leader of Agile Turkey
git is powerful
but you have to know using it properly
Are you using git
if all you do is commit-push-pull
use dropbox instead
ANTIPATTERN DANGER
as if it is dropbox ?
learn how git works
no worries, I will cover how git behaves
the way it keeps
FILES & FOLDERS
working copy
staging area
objects database
repository
the way it keeps
REFERENCES
directed acyclic graph
keeping snapshots
traversing graph
branches, tags, heads
git has 2 mechanisms
Source Code
Working Copy
you want to version changes
Source Code
Working Copy
$ git init
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
initializing repo
Source Code
Working Copy
$ git init --bare
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
initializing bare repo
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git add .
preparing commits
folder
folder
folder
file
file
file
$ git add .
preparing commits
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git add .
preparing commits
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git commit -m “initial commit”
commi!ing
$ git commit -m “initial commit”
commi!ing
folder
folder
folder
file
file
file
commit
branch
HEAD
For more details, refer to book
Git Internals by Scott Chacon
folder
folder
folder
file
file
file
commit
$ git commit -m “initial commit”
commi!ing
folder
commit
branch
HEAD
folder
file
folder
For more details, refer to book
Git Internals by Scott Chacon
folder
folder
folder
file
file
file
commit
$ git commit -m “initial commit”
commi!ing
folder
commit
folder
file
folder
folder
commit
branch
HEAD
file
For more details, refer to book
Git Internals by Scott Chacon
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git commit -m “initial commit”
commi!ing
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git remote add origin http://upstream.repo
$ git push -u origin master pushing to remote
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
new changes from others are pushed
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git fetch
fetching changes
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git merge FETCHED_HEAD
updating working copy
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git pull
git fetch + git merge
ge!ing changes to source code
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
want to update last commit
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git reset --soft $ git commit --amend/ so" reseting
cannot be reached
folder
folder
folder
file
file
file
commit
folder
commit
folder
file
folder
folder
commit
branch
HEAD
file
For more details, refer to book
Git Internals by Scott Chacon
$ git reset --soft $ git commit --amend/ so" reseting
folder
folder
folder
file
file
file
commit
folder
commit
folder
file
folder
folder
commit
branch
HEAD
file
For more details, refer to book
Git Internals by Scott Chacon
$ git reset --soft $ git commit --amend/ so" reseting
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
want to squash or change last commits
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git reset --mixed
mixed reseting
cannot be reached
removed from staging area
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
want to get rid of last commits
Object Database
.git Folder / Object Database
Cache
Staging Area / The Index
Remote
Upstream Repo / Remote Repo
Server
Source Code
Working Copy
$ git reset --hard
hard reseting
cannot be reached
removed from staging area
removed from working copy
are you brave enough to
jump to any commit ?
jump to a branch
create a branch from a commit
create a branch from a tag
ANTIPATTERN DANGER
$ git checkout feature/PA-121
$ git checkout -b fix/missing-sign-parameter 2449be8
$ git checkout -b hotfix/v1.1 tags/v1
are you sure?
are you brave enough to
jump to any commit ?
do you have
loooooong living
topic branches ?
ANTIPATTERN DANGER
do you have
loooooong living
topic branches ?
welcome to
merge hell
before merging
do you validate commits
back to source ?
ANTIPATTERN DANGER
code review, continuous integration, automated testing…
before merging
do you validate commits
back to source ? areyou
sure?
merge and unmerge
do you o!en want to
just before releases ?
ANTIPATTERN DANGER
merge and unmerge
do you o!en want to
just before releases ?
master
HEAD
TAG/v13
version 14
$ git cherry-pick Every-Single-Commit-We-Want-To-Deploy
the commit graph ?
do you fully understand
ANTIPATTERN DANGER
the commit graph ?
do you fully understand
topic and shared branches, tracking branches, tags, HEADs, merge commits, reverted commits…
Cure?
Commit Early, Commit O"en
Perfect Later, Publish Once
STEP 0
split your single feature
into mini shippable tasks
master
HEAD
TOPIC
ORIGIN/master
refactorings
tasks, like rest endpoints
testable, deployable
each task will have a
branch, not a feature
STEP 1
commit early
commit o!en
no need to compile
no need for CI
it’s only for versioning
do not push
master
HEAD
TOPIC
ORIGIN/master
always pull with rebase
$ git pull --rebase origin master
to get forced pushes securely
to rebase your commits
master
HEAD
TOPIC
STEP 2
ORIGIN/master
always pull with rebase
$ git pull --rebase origin master
to get forced pushes securely
to rebase your commits
master
HEAD
TOPIC
STEP 2
ORIGIN/master
always pull with rebase
$ git pull --rebase origin master
to get forced pushes securely
to rebase your commits
master
HEAD
TOPIC
STEP 2
ORIGIN/master
if you branch is pushed already
$ git push -f
always pull with rebase
$ git pull --rebase origin master
to get forced pushes securely
to rebase your commitsmaster
HEAD
TOPIC
STEP 2
ORIGIN/master
if you branch is pushed already
$ git push -f
Sync source branch a!erwards
$ git fetch origin master:master
perfect later
make it single commit
$ git reset HEAD~3
or
$ git rebase -i HEAD~3
HEAD
TOPIC
STEP 3
ORIGIN/master
tests are passing
app is working
code is reviewed (*)
master
$ git reset HEAD~3 (then commit)
or
$ git rebase -i HEAD~3
HEAD
TOPIC
STEP 3
ORIGIN/master
perfect later
make it single commit
tests are passing
app is working
code is reviewed (*)
master
Use feature flags/toggles
HEAD
TOPIC
STEP 4
ORIGIN/master
if feature should be disabled
merge back to source
$ git checkout master
$ git merge topic
master
Use feature flags/toggles
master
HEAD
TOPIC
STEP 4
ORIGIN/master
if feature should be disabled
merge back to source
$ git checkout master
$ git merge topic
Continuous Integration
validates master branch
continuouslymaster
HEAD
TOPIC
ORIGIN/master
Pull requests can be
used to review code
and to validate before
merging back to master
Scrum tasks are
mapped to commits,
not stories
Github Flow can be
used to govern overall
TAMING
THE POWER OF GIT
make git the king again
Feature flags should be
used whenever possible
Commit early & o"en
perfect later, publish
once philosophy
Deliver frequently
be prepared to send
every single commit
Deleting branches a"er
merge will make your
commit graph readable
Any Other Cures?
use terminal
GUIs are prison balls of developers
it’s ok to use GUIs while checking diffs,
resolving conflicts and viewing commit graph
do not lose
take extra care while using hard reset
$ git reset --merge HEAD~
Use stash $ git stash save “updates local settings to keep db safe”
$ git reset --hard HEAD~
$ git stash apply stash@{0}
Create a new branch $ git checkout -b feature/PA-121
$ git add settings.xml
$ git commit -m “adds new settings config”
Use hard reset
with merge
and commit into it
uncommited changes
TOPIC
HEAD
MASTER
long living branches with care
handle
Squash all commits in your topic branch and 

make them available in working copy
$ git merge --squash fix
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested
$ git add .
$ git commit -m “adds a feature”
$ git branch -D topic
long living branches with care
handle
TOPIC
HEAD
MASTER
$ git merge --squash fix
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested
$ git add .
$ git commit -m “adds a feature”
$ git branch -D topic
Squash all commits in your topic branch and 

make them available in working copy
stop adding
prevent commits from being big ball of muds
every change
stop adding
prevent commits from being big ball of muds
every change
local change sets at intelliJ
stop adding every change
partial add
messages
are
read!
# WHAT
# <issue id> (this commit will...) <subject>
# WHY and HOW
# Explain why this change is being made
# RELATED
# Provide links or keys to any relevant issues or other resources
# REMEMBER
# use lower case in the subject line
# start with a verb in imperative tone in the subject line
# do not end the subject line with a period
# separate subject from body with a blank line
# use the body to explain what and why vs. how
# can use multiple lines with "-" for bullet points in body
$ git config --global commit.template ~/.git-commit-template.txt
$ git config --global commit.cleanup strip
.git-commit-template.txt
use git commit
templates to
create be"er
commit messages
comtmi
messages
are
read!
use git commit
templates to
create be"er
commit messages
comtmi
RECAP
what was really
happened at that time?
LET’S
master
TAG/v1.1
login
HEAD
DETACHED HEAD STATE
$ git checkout cecd95914
Note: checking out 'cecd95914'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
master
TAG/v1.1
login
HEAD
DETACHED HEAD STATE
(login)$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: settings
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging settings
CONFLICT (add/add): Merge conflict in settings
error: Failed to merge in the changes.
Patch failed at 0001 settings
The copy of the patch that failed is found in: .git/rebase-apply/patch
(a16e6e8)$
master
TAG/v1.1
login
HEAD
poor little developer...
master
TAG/v1.1
login
HEAD
$ git checkout master
master
TAG/v1.1
login
HEAD
$ git reflog
aa67e3a2c HEAD@{0}: rebase finished: returning to refs/heads/fix/java-sql-Date-violates-LSR
aa67e3a2c HEAD@{1}: rebase: fixes UnsupportedOperationException while calling toIstant() method of java.sql.Date
a45f3c4e5 HEAD@{2}: rebase: checkout develop
630ddad6e HEAD@{3}: checkout: moving from develop to fix/java-sql-Date-violates-LSR
b26cf7a1a HEAD@{4}: rebase: checkout develop
630ddad6e HEAD@{5}: checkout: moving from develop to fix/java-sql-Date-violates-LSR
b26cf7a1a HEAD@{6}: pull: Fast-forward
8b59f8f50 HEAD@{7}: checkout: moving from fix/java-sql-Date-violates-LSR to develop
$ git reflog
630ddad6e
the one we are
searching for
master
TAG/v1.1
login
HEAD
aa67e3a2c HEAD@{0}: rebase finished: returning to refs/heads/fix/java-sql-Date-violates-LSR
aa67e3a2c HEAD@{1}: rebase: fixes UnsupportedOperationException while calling toIstant() method of java.sql.Date
a45f3c4e5 HEAD@{2}: rebase: checkout develop
630ddad6e HEAD@{3}: checkout: moving from develop to fix/java-sql-Date-violates-LSR
b26cf7a1a HEAD@{4}: rebase: checkout develop
630ddad6e HEAD@{5}: checkout: moving from develop to fix/java-sql-Date-violates-LSR
b26cf7a1a HEAD@{6}: pull: Fast-forward
8b59f8f50 HEAD@{7}: checkout: moving from fix/java-sql-Date-violates-LSR to develop
master
typofix
TAG/v1.1
login
HEAD
$ git branch typofix 630ddad6e
master
typofix
TAG/v1.1
login
HEAD
$ git branch typofix 630ddad6e
KEEP CALM, NOTHING WILL BE LOST
LEMi ORHAN ERGiN
agile software craftsman @ iyzico
/lemiorhan
lemiorhanergin.com
@lemiorhan

More Related Content

What's hot (20)

PPTX
12 Best Android Libraries to use in 2021
Mobcoder
 
KEY
The everyday developer's guide to version control with Git
E Carter
 
PDF
Building Rich Applications with Appcelerator
Matt Raible
 
PDF
Graalvm with Groovy and Kotlin - Greach 2019
Alberto De Ávila Hernández
 
PPTX
Git basics to advance with diagrams
Dilum Navanjana
 
KEY
Gittalk
prtinsley
 
PDF
Introduction to Git
Rick Umali
 
PPT
Git101
Jason Noble
 
PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
PPTX
DevOps + MongoDB Serverless = 
Lauren Hayward Schaefer
 
PDF
Building CI/CD Pipelines for MongoDB Realm Apps
Lauren Hayward Schaefer
 
PDF
Android Internal Library Management
Kelly Shuster
 
PDF
Modern Web 2016: Using Golang to build a smart IM Bot
Evan Lin
 
PDF
Develop Android/iOS app using golang
SeongJae Park
 
PDF
Versions
Olivier DELHOMME
 
ODP
Migrating to Git: Rethinking the Commit
Kim Moir
 
PDF
How To Use The Codename One Sources
Shai Almog
 
PDF
React native
Omid Nikrah
 
PDF
Developing in the Fastlane -> How LookLive uses Fastlane to automate and spee...
Donny Wals
 
PDF
Free The Enterprise With Ruby & Master Your Own Domain
Ken Collins
 
12 Best Android Libraries to use in 2021
Mobcoder
 
The everyday developer's guide to version control with Git
E Carter
 
Building Rich Applications with Appcelerator
Matt Raible
 
Graalvm with Groovy and Kotlin - Greach 2019
Alberto De Ávila Hernández
 
Git basics to advance with diagrams
Dilum Navanjana
 
Gittalk
prtinsley
 
Introduction to Git
Rick Umali
 
Git101
Jason Noble
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
DevOps + MongoDB Serverless = 
Lauren Hayward Schaefer
 
Building CI/CD Pipelines for MongoDB Realm Apps
Lauren Hayward Schaefer
 
Android Internal Library Management
Kelly Shuster
 
Modern Web 2016: Using Golang to build a smart IM Bot
Evan Lin
 
Develop Android/iOS app using golang
SeongJae Park
 
Migrating to Git: Rethinking the Commit
Kim Moir
 
How To Use The Codename One Sources
Shai Almog
 
React native
Omid Nikrah
 
Developing in the Fastlane -> How LookLive uses Fastlane to automate and spee...
Donny Wals
 
Free The Enterprise With Ruby & Master Your Own Domain
Ken Collins
 

Similar to Git Anti-Patterns: How To Mess Up With Git and Love it Again (20)

PPTX
Git-ing out of your git messes
Katie Sylor-Miller
 
PPTX
Git and git workflow best practice
Majid Hosseini
 
PDF
Git tutorial
mobaires
 
KEY
Use git the proper way
Jaime Buelta
 
PPTX
Working with Git
Sanghoon Hong
 
PDF
Git with the flow
Dana White
 
PPTX
MakingGitWorkForYou
Kwen Peterson
 
PPTX
Techoalien git
Aditya Tiwari
 
PPTX
Techoalien git
Aditya Tiwari
 
PPTX
Techoalien git
Aditya Tiwari
 
PPTX
Mastering GIT
Hasnaeen Rahman
 
PDF
Advanced Git - Functionality and Features
All Things Open
 
PPTX
Git presentation bixlabs
Bixlabs
 
PPTX
Git session Dropsolid.com
dropsolid
 
PPTX
Session git
Roni Saha
 
PDF
Source Code Management with Git
Things Lab
 
PDF
Git basics
Surabhi Gupta
 
PPTX
Git tutorial
Ananth Kumar
 
PDF
Git and github 101
Senthilkumar Gopal
 
PDF
Git cheat sheet
Piyush Mittal
 
Git-ing out of your git messes
Katie Sylor-Miller
 
Git and git workflow best practice
Majid Hosseini
 
Git tutorial
mobaires
 
Use git the proper way
Jaime Buelta
 
Working with Git
Sanghoon Hong
 
Git with the flow
Dana White
 
MakingGitWorkForYou
Kwen Peterson
 
Techoalien git
Aditya Tiwari
 
Techoalien git
Aditya Tiwari
 
Techoalien git
Aditya Tiwari
 
Mastering GIT
Hasnaeen Rahman
 
Advanced Git - Functionality and Features
All Things Open
 
Git presentation bixlabs
Bixlabs
 
Git session Dropsolid.com
dropsolid
 
Session git
Roni Saha
 
Source Code Management with Git
Things Lab
 
Git basics
Surabhi Gupta
 
Git tutorial
Ananth Kumar
 
Git and github 101
Senthilkumar Gopal
 
Git cheat sheet
Piyush Mittal
 
Ad

More from Lemi Orhan Ergin (20)

PDF
Clean Software Design: The Practices to Make The Design Simple
Lemi Orhan Ergin
 
PDF
Unwritten Manual for Pair Programming
Lemi Orhan Ergin
 
PDF
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
Lemi Orhan Ergin
 
PDF
Yeni Nesil Yazılım Kültürü: Daha İyi Profesyoneller, Daha Kaliteli Yazılım, D...
Lemi Orhan Ergin
 
PDF
Irresponsible Disclosure: Short Handbook of an Ethical Developer
Lemi Orhan Ergin
 
PDF
Scrum Events and Artifacts in Action
Lemi Orhan Ergin
 
PDF
DevOps & Technical Agility: From Theory to Practice
Lemi Orhan Ergin
 
PDF
Fighting with Waste Driven Development - XP Days Ukraine 2017
Lemi Orhan Ergin
 
PDF
Waste Driven Development - Agile Coaching Serbia Meetup
Lemi Orhan Ergin
 
PDF
Yazılım Geliştirme Kültürünün Kodları: Motivasyon, Teknik Mükemmellik ve İnov...
Lemi Orhan Ergin
 
PDF
Clean Software Design - DevNot Summit Istanbul 2017
Lemi Orhan Ergin
 
PDF
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
PDF
Let The Elephants Leave The Room - Remove Waste in Software Development - Bos...
Lemi Orhan Ergin
 
PDF
Happy Developer's Guide to the Galaxy: Thinking About Motivation of Developers
Lemi Orhan Ergin
 
PDF
Git - Bildiğiniz Gibi Değil
Lemi Orhan Ergin
 
PDF
Code Your Agility - Tips for Boosting Technical Agility in Your Organization
Lemi Orhan Ergin
 
PDF
Lost in Motivation in an Agile World
Lemi Orhan Ergin
 
PDF
TDD - Inevitable Challenge for Software Developers (phpkonf15 keynote)
Lemi Orhan Ergin
 
PDF
Unleashed Power Behind The Myths: Pair Programming (CraftSummit15)
Lemi Orhan Ergin
 
PDF
Trespassing The Forgotten and Abandoned: Ethics in Software Development
Lemi Orhan Ergin
 
Clean Software Design: The Practices to Make The Design Simple
Lemi Orhan Ergin
 
Unwritten Manual for Pair Programming
Lemi Orhan Ergin
 
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
Lemi Orhan Ergin
 
Yeni Nesil Yazılım Kültürü: Daha İyi Profesyoneller, Daha Kaliteli Yazılım, D...
Lemi Orhan Ergin
 
Irresponsible Disclosure: Short Handbook of an Ethical Developer
Lemi Orhan Ergin
 
Scrum Events and Artifacts in Action
Lemi Orhan Ergin
 
DevOps & Technical Agility: From Theory to Practice
Lemi Orhan Ergin
 
Fighting with Waste Driven Development - XP Days Ukraine 2017
Lemi Orhan Ergin
 
Waste Driven Development - Agile Coaching Serbia Meetup
Lemi Orhan Ergin
 
Yazılım Geliştirme Kültürünün Kodları: Motivasyon, Teknik Mükemmellik ve İnov...
Lemi Orhan Ergin
 
Clean Software Design - DevNot Summit Istanbul 2017
Lemi Orhan Ergin
 
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
Let The Elephants Leave The Room - Remove Waste in Software Development - Bos...
Lemi Orhan Ergin
 
Happy Developer's Guide to the Galaxy: Thinking About Motivation of Developers
Lemi Orhan Ergin
 
Git - Bildiğiniz Gibi Değil
Lemi Orhan Ergin
 
Code Your Agility - Tips for Boosting Technical Agility in Your Organization
Lemi Orhan Ergin
 
Lost in Motivation in an Agile World
Lemi Orhan Ergin
 
TDD - Inevitable Challenge for Software Developers (phpkonf15 keynote)
Lemi Orhan Ergin
 
Unleashed Power Behind The Myths: Pair Programming (CraftSummit15)
Lemi Orhan Ergin
 
Trespassing The Forgotten and Abandoned: Ethics in Software Development
Lemi Orhan Ergin
 
Ad

Recently uploaded (20)

PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 

Git Anti-Patterns: How To Mess Up With Git and Love it Again

  • 1. LEMi ORHAN ERGiN agile software craftsman @ iyzico GITANTI PATTERNS How To Mess Up With Git and Love It Again
  • 2. /lemiorhan lemiorhanergin.com @lemiorhan meetup.scturkey.org agileturkey.org dev.iyzipay.com LEMi ORHAN ERGiN agile software craftsman @ iyzico agile practice lead at iyzico developing software since 2001 worked at Sony, eBay/GittiGidiyor, ACM consultant, architect, mentor, developer founder of Software Craftsmanship Turkey ex community leader of Agile Turkey
  • 3. git is powerful but you have to know using it properly
  • 4. Are you using git if all you do is commit-push-pull use dropbox instead ANTIPATTERN DANGER as if it is dropbox ?
  • 5. learn how git works no worries, I will cover how git behaves
  • 6. the way it keeps FILES & FOLDERS working copy staging area objects database repository the way it keeps REFERENCES directed acyclic graph keeping snapshots traversing graph branches, tags, heads git has 2 mechanisms
  • 7. Source Code Working Copy you want to version changes
  • 8. Source Code Working Copy $ git init Object Database .git Folder / Object Database Cache Staging Area / The Index initializing repo
  • 9. Source Code Working Copy $ git init --bare Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server initializing bare repo
  • 10. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git add . preparing commits
  • 12. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git add . preparing commits
  • 13. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git commit -m “initial commit” commi!ing
  • 14. $ git commit -m “initial commit” commi!ing folder folder folder file file file commit branch HEAD For more details, refer to book Git Internals by Scott Chacon
  • 15. folder folder folder file file file commit $ git commit -m “initial commit” commi!ing folder commit branch HEAD folder file folder For more details, refer to book Git Internals by Scott Chacon
  • 16. folder folder folder file file file commit $ git commit -m “initial commit” commi!ing folder commit folder file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon
  • 17. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git commit -m “initial commit” commi!ing
  • 18. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git remote add origin http://upstream.repo $ git push -u origin master pushing to remote
  • 19. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy new changes from others are pushed
  • 20. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git fetch fetching changes
  • 21. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git merge FETCHED_HEAD updating working copy
  • 22. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git pull git fetch + git merge ge!ing changes to source code
  • 23. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy want to update last commit
  • 24. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --soft $ git commit --amend/ so" reseting cannot be reached
  • 25. folder folder folder file file file commit folder commit folder file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon $ git reset --soft $ git commit --amend/ so" reseting
  • 26. folder folder folder file file file commit folder commit folder file folder folder commit branch HEAD file For more details, refer to book Git Internals by Scott Chacon $ git reset --soft $ git commit --amend/ so" reseting
  • 27. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy want to squash or change last commits
  • 28. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --mixed mixed reseting cannot be reached removed from staging area
  • 29. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy want to get rid of last commits
  • 30. Object Database .git Folder / Object Database Cache Staging Area / The Index Remote Upstream Repo / Remote Repo Server Source Code Working Copy $ git reset --hard hard reseting cannot be reached removed from staging area removed from working copy
  • 31. are you brave enough to jump to any commit ? jump to a branch create a branch from a commit create a branch from a tag ANTIPATTERN DANGER $ git checkout feature/PA-121 $ git checkout -b fix/missing-sign-parameter 2449be8 $ git checkout -b hotfix/v1.1 tags/v1
  • 32. are you sure? are you brave enough to jump to any commit ?
  • 33. do you have loooooong living topic branches ? ANTIPATTERN DANGER
  • 34. do you have loooooong living topic branches ? welcome to merge hell
  • 35. before merging do you validate commits back to source ? ANTIPATTERN DANGER code review, continuous integration, automated testing…
  • 36. before merging do you validate commits back to source ? areyou sure?
  • 37. merge and unmerge do you o!en want to just before releases ? ANTIPATTERN DANGER
  • 38. merge and unmerge do you o!en want to just before releases ? master HEAD TAG/v13 version 14 $ git cherry-pick Every-Single-Commit-We-Want-To-Deploy
  • 39. the commit graph ? do you fully understand ANTIPATTERN DANGER
  • 40. the commit graph ? do you fully understand topic and shared branches, tracking branches, tags, HEADs, merge commits, reverted commits…
  • 41. Cure?
  • 42. Commit Early, Commit O"en Perfect Later, Publish Once
  • 43. STEP 0 split your single feature into mini shippable tasks master HEAD TOPIC ORIGIN/master refactorings tasks, like rest endpoints testable, deployable each task will have a branch, not a feature
  • 44. STEP 1 commit early commit o!en no need to compile no need for CI it’s only for versioning do not push master HEAD TOPIC ORIGIN/master
  • 45. always pull with rebase $ git pull --rebase origin master to get forced pushes securely to rebase your commits master HEAD TOPIC STEP 2 ORIGIN/master
  • 46. always pull with rebase $ git pull --rebase origin master to get forced pushes securely to rebase your commits master HEAD TOPIC STEP 2 ORIGIN/master
  • 47. always pull with rebase $ git pull --rebase origin master to get forced pushes securely to rebase your commits master HEAD TOPIC STEP 2 ORIGIN/master if you branch is pushed already $ git push -f
  • 48. always pull with rebase $ git pull --rebase origin master to get forced pushes securely to rebase your commitsmaster HEAD TOPIC STEP 2 ORIGIN/master if you branch is pushed already $ git push -f Sync source branch a!erwards $ git fetch origin master:master
  • 49. perfect later make it single commit $ git reset HEAD~3 or $ git rebase -i HEAD~3 HEAD TOPIC STEP 3 ORIGIN/master tests are passing app is working code is reviewed (*) master
  • 50. $ git reset HEAD~3 (then commit) or $ git rebase -i HEAD~3 HEAD TOPIC STEP 3 ORIGIN/master perfect later make it single commit tests are passing app is working code is reviewed (*) master
  • 51. Use feature flags/toggles HEAD TOPIC STEP 4 ORIGIN/master if feature should be disabled merge back to source $ git checkout master $ git merge topic master
  • 52. Use feature flags/toggles master HEAD TOPIC STEP 4 ORIGIN/master if feature should be disabled merge back to source $ git checkout master $ git merge topic
  • 53. Continuous Integration validates master branch continuouslymaster HEAD TOPIC ORIGIN/master Pull requests can be used to review code and to validate before merging back to master Scrum tasks are mapped to commits, not stories Github Flow can be used to govern overall TAMING THE POWER OF GIT make git the king again Feature flags should be used whenever possible Commit early & o"en perfect later, publish once philosophy Deliver frequently be prepared to send every single commit Deleting branches a"er merge will make your commit graph readable
  • 55. use terminal GUIs are prison balls of developers it’s ok to use GUIs while checking diffs, resolving conflicts and viewing commit graph
  • 56. do not lose take extra care while using hard reset $ git reset --merge HEAD~ Use stash $ git stash save “updates local settings to keep db safe” $ git reset --hard HEAD~ $ git stash apply stash@{0} Create a new branch $ git checkout -b feature/PA-121 $ git add settings.xml $ git commit -m “adds new settings config” Use hard reset with merge and commit into it uncommited changes
  • 57. TOPIC HEAD MASTER long living branches with care handle Squash all commits in your topic branch and 
 make them available in working copy $ git merge --squash fix Squash commit -- not updating HEAD Automatic merge went well; stopped before committing as requested $ git add . $ git commit -m “adds a feature” $ git branch -D topic
  • 58. long living branches with care handle TOPIC HEAD MASTER $ git merge --squash fix Squash commit -- not updating HEAD Automatic merge went well; stopped before committing as requested $ git add . $ git commit -m “adds a feature” $ git branch -D topic Squash all commits in your topic branch and 
 make them available in working copy
  • 59. stop adding prevent commits from being big ball of muds every change
  • 60. stop adding prevent commits from being big ball of muds every change local change sets at intelliJ
  • 61. stop adding every change partial add
  • 62. messages are read! # WHAT # <issue id> (this commit will...) <subject> # WHY and HOW # Explain why this change is being made # RELATED # Provide links or keys to any relevant issues or other resources # REMEMBER # use lower case in the subject line # start with a verb in imperative tone in the subject line # do not end the subject line with a period # separate subject from body with a blank line # use the body to explain what and why vs. how # can use multiple lines with "-" for bullet points in body $ git config --global commit.template ~/.git-commit-template.txt $ git config --global commit.cleanup strip .git-commit-template.txt use git commit templates to create be"er commit messages comtmi
  • 63. messages are read! use git commit templates to create be"er commit messages comtmi
  • 64. RECAP what was really happened at that time? LET’S
  • 65. master TAG/v1.1 login HEAD DETACHED HEAD STATE $ git checkout cecd95914 Note: checking out 'cecd95914'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
  • 66. master TAG/v1.1 login HEAD DETACHED HEAD STATE (login)$ git rebase master First, rewinding head to replay your work on top of it... Applying: settings Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging settings CONFLICT (add/add): Merge conflict in settings error: Failed to merge in the changes. Patch failed at 0001 settings The copy of the patch that failed is found in: .git/rebase-apply/patch (a16e6e8)$
  • 69. master TAG/v1.1 login HEAD $ git reflog aa67e3a2c HEAD@{0}: rebase finished: returning to refs/heads/fix/java-sql-Date-violates-LSR aa67e3a2c HEAD@{1}: rebase: fixes UnsupportedOperationException while calling toIstant() method of java.sql.Date a45f3c4e5 HEAD@{2}: rebase: checkout develop 630ddad6e HEAD@{3}: checkout: moving from develop to fix/java-sql-Date-violates-LSR b26cf7a1a HEAD@{4}: rebase: checkout develop 630ddad6e HEAD@{5}: checkout: moving from develop to fix/java-sql-Date-violates-LSR b26cf7a1a HEAD@{6}: pull: Fast-forward 8b59f8f50 HEAD@{7}: checkout: moving from fix/java-sql-Date-violates-LSR to develop
  • 70. $ git reflog 630ddad6e the one we are searching for master TAG/v1.1 login HEAD aa67e3a2c HEAD@{0}: rebase finished: returning to refs/heads/fix/java-sql-Date-violates-LSR aa67e3a2c HEAD@{1}: rebase: fixes UnsupportedOperationException while calling toIstant() method of java.sql.Date a45f3c4e5 HEAD@{2}: rebase: checkout develop 630ddad6e HEAD@{3}: checkout: moving from develop to fix/java-sql-Date-violates-LSR b26cf7a1a HEAD@{4}: rebase: checkout develop 630ddad6e HEAD@{5}: checkout: moving from develop to fix/java-sql-Date-violates-LSR b26cf7a1a HEAD@{6}: pull: Fast-forward 8b59f8f50 HEAD@{7}: checkout: moving from fix/java-sql-Date-violates-LSR to develop
  • 72. master typofix TAG/v1.1 login HEAD $ git branch typofix 630ddad6e KEEP CALM, NOTHING WILL BE LOST
  • 73. LEMi ORHAN ERGiN agile software craftsman @ iyzico /lemiorhan lemiorhanergin.com @lemiorhan