SlideShare a Scribd company logo
@durdn#DevoxxPL
Platinum Sponsors:
Transformative Git Practices
Nicola Paolucci
New Techniques for Hyper-productivity
git push --force
Today we’ll cover some powerful Git goodies
Worktree clones Painless sub-projectsThe magic of --fixup
For when you have to
work concurrently on
multiple long running
branches
You can use git subtree
to handle external
libraries in a clean and
efficient way
A powerful technique to
cleanup your history
before sharing with it the
team
and a final, cool topic…
@durdn
Git Worktree
Local clones for parallel work
The old simple way: branch, commit, push
master
HEAD
HEAD
new-feature
git checkout -b new-feature
Uns
@durdn
It’s clumsy to work in parallel
on multiple branches
Or are a pro at using
the Stash (which is
cool btw)
You either work
around it having
intermediate WIP
commits
It leaves hanging
uncommitted work
lying around
To work on 2+ branches at the same time
@durdn
git stash is awesome
It’s a way to temporarily store your unsaved work
on a stack of patches
stash@{0}
stash@{1}
stash@{2}
stash@{3}
git stash save
@durdn
But there’s a new way: git worktree
Available since Git 2.5
git worktree creates additional clones inside your project
Add a new worktree
git worktree add 
-b feature/PRJ-1-new-fancy-button 
fancy-button
Branch to checkout in clone
Folder where to checkout
It shows the folder
git worktree list - shows the worktrees created
And the branch is pointing at
Where the additional cloned has
been checked out
So that you have an immediate
overview of all the trees you have
created
git worktree list$
/Users/np/p/dac f1f7f8b [master]
/Users/np/p/dac/git-the-all-new-modern-workflow 7fe9096 [blog/git-…-new-modern-workflow]
/Users/np/p/dac/provision-a-cluster-with-rancher b4b84fb [blog/provision-…-with-rancher]
/Users/np/p/dac/static-site-with-pipelines-and-middleman d6bd9fd [blog/static-site-…-middleman]
git worktree prune - once you’re done with a clone
git worktree prune$
rm -rf fancy-button$
Demo Time!
Let’s see how “git worktree” works in
practice
Replace the normal branching?Keep working while testingBetter work in parallel
Why git worktree is a great choice
Having multiple clones
with all the branches
you’re working on
available in your repo is
a big win.
If you have a big battery
of tests which are slow
to run, you can run them
in a worktree clone while
you keep working.
When you get used to
worktrees, they become
very natural for any
feature branch work.
@durdn
The magic of --fixup
Smooth history cleanup for perfectionists
@durdn
It’s great to work in small chunks
@durdn
There’s a tension between…
Commits as
throw away
save points
Commits as a
polished
meaningful way
to communicate
a feature
@durdn
There’s a way to square the circle
@durdn
Helps you clean up your private branches
before publishing them interactively
What is an
--interactive rebase?
master
feature
First step: Turn on the “autosquash” feature
git config --global rebase.autosquash true$
@durdn
Work in small throwaway bits, use
commits as save points
as you please
Fixup
Annotate your raw commits with “--fixup” or “--squash”
Squash
Use fixup to quickly fix
problems in a commit,
without the need to change
or add to the commit
message
For additions to a commit
where you want to add also
an additional note to the
commit message
git commit --fixup <commit>$
git commit --squash -m”Add to feature” <commit>$
Fixup
Annotate your raw commits with “--fixup” or “--squash”
Squash
Use fixup to quickly fix
problems in a commit,
without the need to change
or add to the commit
message
For additions to a commit
where you want to add also
an additional note to the
commit message
git commit --fixup :/<string pattern>$
git commit --fixup :/PRJ-123$
@durdn
Rebase is now pre-filled and easy
Demo Time!
Let’s see how “--fixup” and “--squash” work
in practice
Let’s talk about project dependencies
git subtree
Extract project
Alternative to git submodule to handle
external dependencies.
Inject dependency
It allows you to inject an external
project into a sub-folder
Introduced in 1.7.11
It can be also used to extract a
sub-folder as separate project
Clean integration pointsStores in regular commitsNo training
When and why is git subtree a great choice
Does not require your
entire team to be trained
in the use of the
command
The command stores
the external
dependency in regular
Git commits. Squashing
the history optionally.
It makes it easy to see
when integrations
happened and makes it
easy to revert them.
Syntax to inject a project
Command to inject project
git subtree add 
--prefix target-folder 
https://bitbucket.org/team/sub.git 
master --squash
Folder where to insert code
Repository URL
v1.1
Under the hood of git subtree
commit ab54c4e0b75c3107e3e773ab9b39268abddca002
Author: Nicola Paolucci <npaolucci@atlassian.com>
Date: Tue Sep 29 15:27:35 2015 +0200
Squashed ‘src/sub-project‘ content from commit df563ed
git-subtree-dir: src/sub-project
git-subtree-split: df563ed15fa6…6b2e95d3
Result of git subtree add
commit 8fb507baf7b270c30c822b27e262d0b44819b4c5
Merge: 606cd3e ab54c4e
Author: Nicola Paolucci <npaolucci@atlassian.com>
Date: Tue Sep 29 15:27:35 2015 +0200
Merge commit 'ab54c4e0b75c3107e3e773ab9b39268abddca002' as '.vim/bundle/fireplace'
commit ab54c4e0b75c3107e3e773ab9b39268abddca002
Author: Nicola Paolucci <npaolucci@atlassian.com>
Date: Tue Sep 29 15:27:35 2015 +0200
Squashed '.vim/bundle/fireplace/' content from commit df563ed
git-subtree-dir: .vim/bundle/fireplace
git-subtree-split: df563ed15fa685ce2508bf16b3ca7e176b2e95d3
To keep the sub-project up to date
git subtree pull 
--prefix target-folder 
https://bitbucket.org/team/sub.git 
master --squash
Command to pull project
Folder where to insert code
Repository URL
v1.5
Under the hood of git subtree
commit ab54c4e0b75c3107e3e773ab9b39268abddca002
Author: Nicola Paolucci <npaolucci@atlassian.com>
Date: Tue Sep 29 15:27:35 2015 +0200
Squashed ‘src/sub-project‘ content from commit df563ed
git-subtree-dir: src/sub-project
git-subtree-split: df563ed15fa6…6b2e95d3
Find the symbolic ref matching a hash (sha-1)
sha-1 of last commit pulled
Git plumbing to list all remote refs
Repository URL
git ls-remote https://bitbucket.org/team/sub.git | grep df563ed
df563ed15fa685ce2508bf16b3ca7e176b2e95d3 v1.1
5eaff1232acedeca565er7e1333234dacccebfff v1.5
git ls-remote https://bitbucket.org/team/sub.git | grep <sha-1>
Aliases to make your life easier!
[alias]
sba = "!f() { git subtree add --prefix $2 $1 master --squash; }; f"
sbu = "!f() { git subtree pull --prefix $2 $1 master --squash; }; f"
Alias section of your .gitconfig
http://bit.do/git-aliases
How to use the aliases
git sba <repo URL> <destination-folder>
git sba https://bitbucket.org/team/sub.git src/sub
When everyone in the
team must work on
sub-projects
When you have
constant updates to
your dependencies
When you have many
dependencies
When NOT to use git subtree
@durdn
For complex project dependencies
Use a dependency tool.
Really.
Alternatives?
Read my rant
on project
dependencies
http://bit.do/git-dep
@durdn
How to extract a project
Let’s learn how to use subtree split
Git subtree to extract a project
Command to split out project
git subtree split 
--prefix my/project/ 
--branch extracted
Folder prefix to extract
where we store it
Push to new remote
We can remove the contents of the
folder from the repo
Import extracted branch
Initialise a new repo and import the
extracted branch
Remove from old repo
After we imported the code we can
push it to a new repository
git rm -rf my/project
git init
git pull ../path/ extracted
git remote add origin …
git push origin -u master
@durdn
Have a Pipeline with your repo
Build your project in the cloud
• Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
• Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
• Big cool statistic
• 2,56
9
• Add-Ons in Marketplace
Deploy to any of these and more!
…
NICOLA PAOLUCCI • ATLASSIAN • @DURDN
Twitter: @durdn
http://bit.do/pipelines
We’ve covered some powerful Git goodies
Worktree clones Painless sub-projectsThe magic of --fixup
For when you have to
work concurrently on
multiple long running
branches
You can use git subtree
to handle external
libraries in a clean and
efficient way
A powerful technique to
cleanup your history
before sharing with it the
team
Thank you! Follow me @durdn
NICOLA PAOLUCCI • ATLASSIAN • @DURDN
Twitter: @durdnhttp://bit.do/pipelines
Thank you! Follow me @durdn

More Related Content

What's hot

Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
Giacomo Vacca
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
Docker, Inc.
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
Red Hat Developers
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
Ganesh Samarthyam
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
Automate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsAutomate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOps
Daniel Oh
 
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
Docker, Inc.
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech Talk
Red Hat Developers
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
Larry Cai
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
Erica Windisch
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App EngineDocker, Inc.
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
ZeroTurnaround
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To Running
Giacomo Vacca
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Building a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from YelpBuilding a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from Yelp
dotCloud
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
NGINX, Inc.
 
Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2
dotCloud
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
Jadson Santos
 

What's hot (20)

Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Automate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsAutomate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOps
 
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech Talk
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To Running
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
 
Building a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from YelpBuilding a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from Yelp
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
 
Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
 
Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
 

Viewers also liked

A Scala Corrections Library
A Scala Corrections LibraryA Scala Corrections Library
A Scala Corrections Library
Paul Phillips
 
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance DeploymentsLightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
MongoDB
 
Future of ai on the jvm
Future of ai on the jvmFuture of ai on the jvm
Future of ai on the jvm
Adam Gibson
 
Effective Actors
Effective ActorsEffective Actors
Effective Actors
shinolajla
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and Performance
John Nestor
 
Stateful Distributed Stream Processing
Stateful Distributed Stream ProcessingStateful Distributed Stream Processing
Stateful Distributed Stream Processing
Gyula Fóra
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
What We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the UniverseWhat We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the Universe
Sean Carroll
 
Gifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, MemoryGifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, Memory
Sean Carroll
 

Viewers also liked (9)

A Scala Corrections Library
A Scala Corrections LibraryA Scala Corrections Library
A Scala Corrections Library
 
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance DeploymentsLightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
 
Future of ai on the jvm
Future of ai on the jvmFuture of ai on the jvm
Future of ai on the jvm
 
Effective Actors
Effective ActorsEffective Actors
Effective Actors
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and Performance
 
Stateful Distributed Stream Processing
Stateful Distributed Stream ProcessingStateful Distributed Stream Processing
Stateful Distributed Stream Processing
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
 
What We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the UniverseWhat We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the Universe
 
Gifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, MemoryGifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, Memory
 

Similar to Transformative Git Practices

Git Power Routines
Git Power RoutinesGit Power Routines
Git Power Routines
Nicola Paolucci
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of GitWayne Chen
 
Git
GitGit
Git presentation
Git presentationGit presentation
Git presentation
James Cuzella
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Git
GitGit
Git submodule
Git submoduleGit submodule
Git submodule
Olaf Alders
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
Julien Pivotto
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductortimyates
 
Git more done
Git more doneGit more done
Git more done
Kwen Peterson
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
Wim Godden
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystemFrançois D'Agostini
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 Workshop
Joy Seng
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Lemi Orhan Ergin
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
Jan Krag
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
Federico Panini
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
OlinData
 

Similar to Transformative Git Practices (20)

Git Power Routines
Git Power RoutinesGit Power Routines
Git Power Routines
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of Git
 
Git
GitGit
Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git
GitGit
Git
 
Git submodule
Git submoduleGit submodule
Git submodule
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductor
 
Git more done
Git more doneGit more done
Git more done
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystem
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 Workshop
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it Again
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 

Recently uploaded

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 

Recently uploaded (20)

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 

Transformative Git Practices

  • 1. @durdn#DevoxxPL Platinum Sponsors: Transformative Git Practices Nicola Paolucci New Techniques for Hyper-productivity
  • 3. Today we’ll cover some powerful Git goodies Worktree clones Painless sub-projectsThe magic of --fixup For when you have to work concurrently on multiple long running branches You can use git subtree to handle external libraries in a clean and efficient way A powerful technique to cleanup your history before sharing with it the team and a final, cool topic…
  • 5. The old simple way: branch, commit, push master HEAD HEAD new-feature git checkout -b new-feature Uns
  • 6. @durdn It’s clumsy to work in parallel on multiple branches
  • 7. Or are a pro at using the Stash (which is cool btw) You either work around it having intermediate WIP commits It leaves hanging uncommitted work lying around To work on 2+ branches at the same time
  • 8. @durdn git stash is awesome It’s a way to temporarily store your unsaved work on a stack of patches stash@{0} stash@{1} stash@{2} stash@{3} git stash save
  • 9. @durdn But there’s a new way: git worktree Available since Git 2.5
  • 10. git worktree creates additional clones inside your project Add a new worktree git worktree add -b feature/PRJ-1-new-fancy-button fancy-button Branch to checkout in clone Folder where to checkout
  • 11. It shows the folder git worktree list - shows the worktrees created And the branch is pointing at Where the additional cloned has been checked out So that you have an immediate overview of all the trees you have created git worktree list$ /Users/np/p/dac f1f7f8b [master] /Users/np/p/dac/git-the-all-new-modern-workflow 7fe9096 [blog/git-…-new-modern-workflow] /Users/np/p/dac/provision-a-cluster-with-rancher b4b84fb [blog/provision-…-with-rancher] /Users/np/p/dac/static-site-with-pipelines-and-middleman d6bd9fd [blog/static-site-…-middleman]
  • 12. git worktree prune - once you’re done with a clone git worktree prune$ rm -rf fancy-button$
  • 13. Demo Time! Let’s see how “git worktree” works in practice
  • 14. Replace the normal branching?Keep working while testingBetter work in parallel Why git worktree is a great choice Having multiple clones with all the branches you’re working on available in your repo is a big win. If you have a big battery of tests which are slow to run, you can run them in a worktree clone while you keep working. When you get used to worktrees, they become very natural for any feature branch work.
  • 15. @durdn The magic of --fixup Smooth history cleanup for perfectionists
  • 16. @durdn It’s great to work in small chunks
  • 18. Commits as throw away save points Commits as a polished meaningful way to communicate a feature
  • 19. @durdn There’s a way to square the circle
  • 20. @durdn Helps you clean up your private branches before publishing them interactively What is an --interactive rebase? master feature
  • 21. First step: Turn on the “autosquash” feature git config --global rebase.autosquash true$
  • 22. @durdn Work in small throwaway bits, use commits as save points as you please
  • 23. Fixup Annotate your raw commits with “--fixup” or “--squash” Squash Use fixup to quickly fix problems in a commit, without the need to change or add to the commit message For additions to a commit where you want to add also an additional note to the commit message git commit --fixup <commit>$ git commit --squash -m”Add to feature” <commit>$
  • 24. Fixup Annotate your raw commits with “--fixup” or “--squash” Squash Use fixup to quickly fix problems in a commit, without the need to change or add to the commit message For additions to a commit where you want to add also an additional note to the commit message git commit --fixup :/<string pattern>$ git commit --fixup :/PRJ-123$
  • 25. @durdn Rebase is now pre-filled and easy
  • 26. Demo Time! Let’s see how “--fixup” and “--squash” work in practice
  • 27. Let’s talk about project dependencies
  • 28. git subtree Extract project Alternative to git submodule to handle external dependencies. Inject dependency It allows you to inject an external project into a sub-folder Introduced in 1.7.11 It can be also used to extract a sub-folder as separate project
  • 29. Clean integration pointsStores in regular commitsNo training When and why is git subtree a great choice Does not require your entire team to be trained in the use of the command The command stores the external dependency in regular Git commits. Squashing the history optionally. It makes it easy to see when integrations happened and makes it easy to revert them.
  • 30. Syntax to inject a project Command to inject project git subtree add --prefix target-folder https://bitbucket.org/team/sub.git master --squash Folder where to insert code Repository URL v1.1
  • 31. Under the hood of git subtree commit ab54c4e0b75c3107e3e773ab9b39268abddca002 Author: Nicola Paolucci <npaolucci@atlassian.com> Date: Tue Sep 29 15:27:35 2015 +0200 Squashed ‘src/sub-project‘ content from commit df563ed git-subtree-dir: src/sub-project git-subtree-split: df563ed15fa6…6b2e95d3
  • 32. Result of git subtree add commit 8fb507baf7b270c30c822b27e262d0b44819b4c5 Merge: 606cd3e ab54c4e Author: Nicola Paolucci <npaolucci@atlassian.com> Date: Tue Sep 29 15:27:35 2015 +0200 Merge commit 'ab54c4e0b75c3107e3e773ab9b39268abddca002' as '.vim/bundle/fireplace' commit ab54c4e0b75c3107e3e773ab9b39268abddca002 Author: Nicola Paolucci <npaolucci@atlassian.com> Date: Tue Sep 29 15:27:35 2015 +0200 Squashed '.vim/bundle/fireplace/' content from commit df563ed git-subtree-dir: .vim/bundle/fireplace git-subtree-split: df563ed15fa685ce2508bf16b3ca7e176b2e95d3
  • 33. To keep the sub-project up to date git subtree pull --prefix target-folder https://bitbucket.org/team/sub.git master --squash Command to pull project Folder where to insert code Repository URL v1.5
  • 34. Under the hood of git subtree commit ab54c4e0b75c3107e3e773ab9b39268abddca002 Author: Nicola Paolucci <npaolucci@atlassian.com> Date: Tue Sep 29 15:27:35 2015 +0200 Squashed ‘src/sub-project‘ content from commit df563ed git-subtree-dir: src/sub-project git-subtree-split: df563ed15fa6…6b2e95d3
  • 35. Find the symbolic ref matching a hash (sha-1) sha-1 of last commit pulled Git plumbing to list all remote refs Repository URL git ls-remote https://bitbucket.org/team/sub.git | grep df563ed df563ed15fa685ce2508bf16b3ca7e176b2e95d3 v1.1 5eaff1232acedeca565er7e1333234dacccebfff v1.5 git ls-remote https://bitbucket.org/team/sub.git | grep <sha-1>
  • 36. Aliases to make your life easier! [alias] sba = "!f() { git subtree add --prefix $2 $1 master --squash; }; f" sbu = "!f() { git subtree pull --prefix $2 $1 master --squash; }; f" Alias section of your .gitconfig http://bit.do/git-aliases
  • 37. How to use the aliases git sba <repo URL> <destination-folder> git sba https://bitbucket.org/team/sub.git src/sub
  • 38. When everyone in the team must work on sub-projects When you have constant updates to your dependencies When you have many dependencies When NOT to use git subtree
  • 39. @durdn For complex project dependencies Use a dependency tool. Really.
  • 40. Alternatives? Read my rant on project dependencies http://bit.do/git-dep
  • 41. @durdn How to extract a project Let’s learn how to use subtree split
  • 42. Git subtree to extract a project Command to split out project git subtree split --prefix my/project/ --branch extracted Folder prefix to extract where we store it
  • 43. Push to new remote We can remove the contents of the folder from the repo Import extracted branch Initialise a new repo and import the extracted branch Remove from old repo After we imported the code we can push it to a new repository git rm -rf my/project git init git pull ../path/ extracted git remote add origin … git push origin -u master
  • 44. @durdn Have a Pipeline with your repo Build your project in the cloud
  • 45. • Big cool statistic • 2,56 9 • Add-Ons in Marketplace
  • 46. • Big cool statistic • 2,56 9 • Add-Ons in Marketplace
  • 47. • Big cool statistic • 2,56 9 • Add-Ons in Marketplace
  • 48. Deploy to any of these and more! …
  • 49. NICOLA PAOLUCCI • ATLASSIAN • @DURDN Twitter: @durdn http://bit.do/pipelines
  • 50. We’ve covered some powerful Git goodies Worktree clones Painless sub-projectsThe magic of --fixup For when you have to work concurrently on multiple long running branches You can use git subtree to handle external libraries in a clean and efficient way A powerful technique to cleanup your history before sharing with it the team
  • 51. Thank you! Follow me @durdn
  • 52. NICOLA PAOLUCCI • ATLASSIAN • @DURDN Twitter: @durdnhttp://bit.do/pipelines Thank you! Follow me @durdn