SlideShare a Scribd company logo
1 of 25
Senior Software Engineer
Kalpa Welivitigoda
Git | Beyond Basics
**
๏ Initializing a git repository
๏ Adding files
๏ Committing
๏ Adding remotes
๏ Push/Pull
๏ Status
What we know already
**
WSO2/product-as john/product-as
John’s local filesystem
product-as
Fork
Clone
(origin)
Remote
(upstream)
*
*
We are no alone!
WSO2/product-as bill/product-as
john/product-as
John’s local filesystem
product-as
bob/product-as
Bill’s local filesystem
product-as
Bob’s local filesystem
product-as
*
*
Developing a feature
*
*
Keep up with the changes...
*
*
Merge
Vs.
Rebase
*
*
git merge
$ git checkout feature
$ git merge master
๏ Non destructive mechanism
๏ Additional commit
*
*
git rebase
$ git checkout feature
$ git rebase master
๏ Cleaner commit history
๏ Rewrites the history!!!!
**
๏ Very powerful
๏ Clean the commit history before merging to master
branch
$ git rebase -i HEAD~10
Interactive rebase
# Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log
message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit
**
Split commits | Demo
*
*
git stash
๏ A stack of uncommitted changes
๏ Tracks modified files and staged changes
๏ Useful when switching between branches
**
$ git stash
$ git stash save stash1
git stash...
$ git stash list
$ git stash apply
$ git stash apply stash@{1}
$ git stash drop
$ git stash pop
$ git stash -p
$ git checkout stash@{n} -- {{file_path}}
**
Selective stashing | Demo
**
$ git log --oneline
$ git log --decorate
$ git log --stat
$ git log -- graph --oneline --decorate
$ git shortlog
$ gitk
git log
Log formatting
**
$ git log -3
$ git log --after="2016-09-01"
$ git log --after="yesterday"
$ git log --after="1 week ago"
$ git log --author="John|Mary"
$ git log --grep="WSAS"
$ git log -- pom.xml
$ git log -S "maven-deploy-plugin"
$ git log --no-merges
$ git log -- merges
$ git log <since>...<until>
git log...
Log filtering
**
$ git config --global alias.lo "log --oneline"
$ git lo
git alias
**
$ git checkout feature
$ git cherry-pick 5a63064
git cherry-pick
๏ It’s a new commit !!!!
**
$ git reflog
git reflog
๏ git log shows commits in ancestor order
๏ Reflog shows in the order you last referenced the
commits
**
$ git bisect start
$ git bisect good <good commit hash>
$ git bisect bad <bad commit hash>
$ git bisect reset
git bisect
๏ Used to find the commit that introduced a bug/fix
๏ Do a binary search of the commits
**
Git best practices
๏ Develop features in feature branches
๏ Commit often, perfect later, publish once
๏ Never change published history (it is possible with
push -f, but never ever do it)
๏ Keep your git tree clean (git pull upstream master --rebase)
**
Git best practices...
๏ A commit message has a subject and a body.
๏ Make the commit subject imperative
๏ Link to the JIRA/Git Issue ID
๏ WSAS-1169 : <commit subject>
๏ Resolves #21
**
Reference
๏ https://www.atlassian.com/git/tutorials/advanced-
overview
๏ http://chris.beams.io/posts/git-commit/
๏ https://git-scm.com/doc
**
Questions ?
**
Thank You !

More Related Content

What's hot

Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
Brian K. Vagnini
 

What's hot (20)

Git
GitGit
Git
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Hello git
Hello git Hello git
Hello git
 
GIT - GOOD PRACTICES
GIT - GOOD PRACTICESGIT - GOOD PRACTICES
GIT - GOOD PRACTICES
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git github
Git githubGit github
Git github
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
用 Kotlin 做自動化工具
用 Kotlin 做自動化工具用 Kotlin 做自動化工具
用 Kotlin 做自動化工具
 
Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
Git101
Git101Git101
Git101
 
Kotlin 在 Web 方面的应用
Kotlin 在 Web 方面的应用Kotlin 在 Web 方面的应用
Kotlin 在 Web 方面的应用
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
Gaelyk
GaelykGaelyk
Gaelyk
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
 
以 Ktor 快速打造 Web 應用
以 Ktor 快速打造 Web 應用以 Ktor 快速打造 Web 應用
以 Ktor 快速打造 Web 應用
 

Viewers also liked

The Private API Economy
The Private API EconomyThe Private API Economy
The Private API Economy
WSO2
 
Identity and Entitlement Management Concepts
Identity and Entitlement Management Concepts Identity and Entitlement Management Concepts
Identity and Entitlement Management Concepts
WSO2
 
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
WSO2
 

Viewers also liked (9)

WSO2 Product Release Webinar: WSO2 Application Server 5.3
WSO2 Product Release Webinar: WSO2 Application Server 5.3WSO2 Product Release Webinar: WSO2 Application Server 5.3
WSO2 Product Release Webinar: WSO2 Application Server 5.3
 
The Private API Economy
The Private API EconomyThe Private API Economy
The Private API Economy
 
Alchemy of the API Economy
Alchemy of the API EconomyAlchemy of the API Economy
Alchemy of the API Economy
 
End-to-End Identity Management
End-to-End Identity ManagementEnd-to-End Identity Management
End-to-End Identity Management
 
Identity and Entitlement Management Concepts
Identity and Entitlement Management Concepts Identity and Entitlement Management Concepts
Identity and Entitlement Management Concepts
 
Identity Management for Web Application Developers
Identity Management for Web Application DevelopersIdentity Management for Web Application Developers
Identity Management for Web Application Developers
 
WSO2 Identity Server 5.3.0 - Product Release Webinar
WSO2 Identity Server 5.3.0 - Product Release WebinarWSO2 Identity Server 5.3.0 - Product Release Webinar
WSO2 Identity Server 5.3.0 - Product Release Webinar
 
WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...
WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...
WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...
 
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
 

Similar to Git beyond basics

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
siva ram
 

Similar to Git beyond basics (20)

Git - a powerful version control tool
Git - a powerful version control toolGit - a powerful version control tool
Git - a powerful version control tool
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git basics
Git basicsGit basics
Git basics
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git & gitflow
Git & gitflowGit & gitflow
Git & gitflow
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git
GitGit
Git
 
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
簡單介紹git簡單介紹git
簡單介紹git
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 

Recently uploaded

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Git beyond basics

  • 1. Senior Software Engineer Kalpa Welivitigoda Git | Beyond Basics
  • 2. ** ๏ Initializing a git repository ๏ Adding files ๏ Committing ๏ Adding remotes ๏ Push/Pull ๏ Status What we know already
  • 3. ** WSO2/product-as john/product-as John’s local filesystem product-as Fork Clone (origin) Remote (upstream)
  • 4. * * We are no alone! WSO2/product-as bill/product-as john/product-as John’s local filesystem product-as bob/product-as Bill’s local filesystem product-as Bob’s local filesystem product-as
  • 6. * * Keep up with the changes...
  • 8. * * git merge $ git checkout feature $ git merge master ๏ Non destructive mechanism ๏ Additional commit
  • 9. * * git rebase $ git checkout feature $ git rebase master ๏ Cleaner commit history ๏ Rewrites the history!!!!
  • 10. ** ๏ Very powerful ๏ Clean the commit history before merging to master branch $ git rebase -i HEAD~10 Interactive rebase # Commands: p, pick = use commit r, reword = use commit, but edit the commit message e, edit = use commit, but stop for amending s, squash = use commit, but meld into previous commit f, fixup = like "squash", but discard this commit's log message x, exec = run command (the rest of the line) using shell d, drop = remove commit
  • 12. * * git stash ๏ A stack of uncommitted changes ๏ Tracks modified files and staged changes ๏ Useful when switching between branches
  • 13. ** $ git stash $ git stash save stash1 git stash... $ git stash list $ git stash apply $ git stash apply stash@{1} $ git stash drop $ git stash pop $ git stash -p $ git checkout stash@{n} -- {{file_path}}
  • 15. ** $ git log --oneline $ git log --decorate $ git log --stat $ git log -- graph --oneline --decorate $ git shortlog $ gitk git log Log formatting
  • 16. ** $ git log -3 $ git log --after="2016-09-01" $ git log --after="yesterday" $ git log --after="1 week ago" $ git log --author="John|Mary" $ git log --grep="WSAS" $ git log -- pom.xml $ git log -S "maven-deploy-plugin" $ git log --no-merges $ git log -- merges $ git log <since>...<until> git log... Log filtering
  • 17. ** $ git config --global alias.lo "log --oneline" $ git lo git alias
  • 18. ** $ git checkout feature $ git cherry-pick 5a63064 git cherry-pick ๏ It’s a new commit !!!!
  • 19. ** $ git reflog git reflog ๏ git log shows commits in ancestor order ๏ Reflog shows in the order you last referenced the commits
  • 20. ** $ git bisect start $ git bisect good <good commit hash> $ git bisect bad <bad commit hash> $ git bisect reset git bisect ๏ Used to find the commit that introduced a bug/fix ๏ Do a binary search of the commits
  • 21. ** Git best practices ๏ Develop features in feature branches ๏ Commit often, perfect later, publish once ๏ Never change published history (it is possible with push -f, but never ever do it) ๏ Keep your git tree clean (git pull upstream master --rebase)
  • 22. ** Git best practices... ๏ A commit message has a subject and a body. ๏ Make the commit subject imperative ๏ Link to the JIRA/Git Issue ID ๏ WSAS-1169 : <commit subject> ๏ Resolves #21