SlideShare a Scribd company logo
1
Git on the front line
Nicola Iarocci
2
Who Am INicola Iarocci, a weirdo
Python by Night
I am the author and
maintainer of a few
Python open source
projects: python-eve.org,
python-cerberus.organd
more.
Microsoft MVP
MongoDB Master
I also happen to be a
Microsoft MVP for Visual
Studio and Development
Technologies and a
MongoDB Master.
Communities
I run DevRomagna, a
developers community, and
CoderDojo Ravenna, a
coding club for kids.
http://devromagna.org
C# by Day
I am the author of Sofware
Gestionali Amica, a line of
accounting and invoicing
applications for Italian small
businesses. Check it out at
http://gestionaleamica.com
3
one size does not fit all
git workflows
4
the main branch where the source code of HEAD
always reflects a production-ready state
origin/master
main branch where HEAD always holds the latest
delivered development changes, ready for next release
origin/develop
feature, release and hotfix branches. these always have
a limited life time, since they will be removed eventually
supporting branches
an elegant mental model well suited for packaged
software. Not ideal for frequent release cycles such as
those we have in modern web development
summary
Git Flowa successful git branching model
http://nvie.com/posts/a-successful-git-branching-model/
5
the main branch where the source code of HEAD
always reflects a production-ready state
origin/master
to work on something new, create a descriptively named
branch off of master branch
feature branch
when you need feedback or help, or you think the
branch is ready for merging, open a pull request
pull request & review
a lightweight, branch-based workflow that supports
teams and projects where deployments are made
regularly
summary
GitHub Flowwidely adopted by the open source community
http://scottchacon.com/2011/08/31/github-flow.html
6
Streamline your git experience
aliases
7
git status, succinctly
$ git st
## work
M README.md
$ git config —-global alias.st ‘status -sb’
8
show last commit
$ git last
commit c828339f02f832818f868bbfe457e64bfcc3e64a
Author: Nicola Iarocci <nicola@nicolaiarocci.com>
Date: Thu Oct 19 10:28:42 2017 +0200
first commit
$ git config —-global alias.last ‘log -1 HEAD’
9
quick branch checkout
$ git co mybranch
switched to branch ‘mybranch’
$ git config —-global alias.co ‘checkout’
Hint: git co - works like cd - but between branches (git checkout - works, too)
10
checkout to a new branch
$ git cob newbranch
switched to a new branch ‘mybranch’
$ git config —-global alias.cob ‘checkout -b’
branch is created on the fly
11
amend last commit
$ git amend
<edit commit message>
$ git config —-global alias.amend ‘commit —-amend’
12
add staged changes to last commit
$ git add .
$ git fixup
$ git config —-global alias.fixup ‘commit —-amend —-noedit’
skip editing the commit message
13
unstage changes
$ git st
## work
M README.md
$ git unstage README.md
Unstaged changes after reset:
M README.md
$ git config —-global alias.unstage ‘reset HEAD’
pass no filename to unstage all, or use wildcard
14
show staged changes
$ git diffc
diff —git a/README.md b/README.md
index 2fd9bc4..889c3dc 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
TITLE
+test
$ git config —-global alias.diffc ‘diff —-cached’
15
undo last commit and keep changes
$ git r1
Unstaged changes after reset:
M README.md
$ git config —-global alias.r1 ‘reset HEAD^’
changes are left unstaged
16
undo last commit, discard changes
$ git rh1
HEAD is now at c828339 first commit
$ git config —-global alias.rh1 ‘reset -—hard HEAD^’
use with caution
17
add all changes including untracked,
and commit with message
$ git cm “my commit message”
[mybranch ea88184] my commit message
1 file changed, 1 insertion(+), 1 deletion(-)
!git add -A && git commit -m
18
add all changes excluding untracked,
then commit as WIP
$ git wip
[mybranch ea88184] WIP
1 file changed, 1 insertion(+), 1 deletion(-)
!git add -u && git commit -m WIP
19
add all changes including untracked,
then commit as SAVEPOINT
$ git save
[mybranch ea88184] SAVEPOINT
1 file changed, 1 insertion(+), 1 deletion(-)
!git add -A && git commit -m SAVEPOINT
20
resume work after WIP or SAVEPOINT
$ git undo
Unstaged files after reset:
M README.md
$ git config —-global alias.undo ‘reset HEAD^ —-mixed’
functionally identical to ‘r1’ but makes more sense semantically
21
add changes to commit, then wipe that commit
$ git wipe
HEAD is now at 8da9860 my commit message
$ git reflog
8da9860 HEAD@{0}: reset: moving to HEAD~1
4998619 HEAD@{1}: commit: WIPE SAVEPOINT
$ git reset —hard 4998619
HEAD is now at 4998619 WIPE SAVEPOINT
!git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
now working dir is clean, but I can still go back if need arises (via reflog)
22
hierarchical, git-powered grep
$ git g “event hooks”
CHANGES
1077:- [new] pre_<method> and ``pre_<method>_<resource>`` event hooks are
now
docs/features.rst
1216:Database event hooks
1219:Database event hooks work like request event hooks
$ git config —-global alias.g ‘grep --break --heading --line-number’
faster than standard grep
23
show a tree with all branches
$ git tree
* bbde45f (HEAD -> expand_cerberus_registries) WIP
* 3a25ea7 (origin/master, master) Merge branch ‘use_ordereddict_from_backport_collections_#1070’
|
| * 9fb1a66 Changelog for #1070
| * fa8da19 use OrderedDict from backport_collections
|/
* cee2f7e Merge branch 'support_for_decimal_type_#1048'
|
| * 46af495 Minor changelog fixes for #1048
| * 3bf1930 Support Decimal type MongoDB
|/
!git log --graph --decorate --all --oneline
which brings us to the next topic…
24
push/unpush current branch to remote
$ git publish
$ git unpublish
In .gitconfig:
branch-name = "!git rev-parse --abbrev-ref HEAD"
publish = "!git push -u origin $(git branch-name)"
unpublish = "!git push origin :$(git branch-name)"
and set it to track upstream branch
25
delete branches already merged to master
$ git delete-merged-branches
Deleted branch add_new_user_gravatar_links
Deleted branch assign_unique_key_to_uploads
Deleted branch remember_the_last_activity_per_user
Deleted branch update_kaminari_to_thread_safe_version
“!git branch —-merged master | grep -v '*' | xargs -n 1 git branch -d"
26
shortcut to .config file
$ git ec
<hack away at your .config file>
$ git config —-global alias.ec ‘config —global —e’
27
get my dotfileshttps://github.com/nicolaiarocci/dotfiles
28
keep your history clean and consistent
rebase
Demo
a documentation project
29
reuse recorded resolutions to solve hunk conflicts
rerere
$ git config —-global rerere.enabled true
https://git-scm.com/blog/2010/03/08/rerere.html
30
shows all non-common commits in two branches (@antirez)
rx script
31
Aliases
Streamline your workflow.
Don’t Repeat Yourself.
Consider sharing with team.
Rebase
Keep project history clean,
compact and consistent. Not
as hard as you thought.
Keep Learning
Study more advanced git
features. Consider building
your own scripts.
Pick a Workflow
Don’t be afraid to customize
it just to suit your use case,
project, and team.
You Are a Craftsmansharpen your tools
32
nicolaiarocci.com nicola@nicolaiarocci.com@nicolaiarocci
Thank You!Send feedback or get in touch at
Ad

More Related Content

What's hot (20)

How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee company
Minqi Pan
 
Nebula: Netflix's OSS Gradle Plugins
Nebula: Netflix's OSS Gradle PluginsNebula: Netflix's OSS Gradle Plugins
Nebula: Netflix's OSS Gradle Plugins
Rob Spieldenner
 
Git & SourceTree
Git & SourceTreeGit & SourceTree
Git & SourceTree
Tu Tran
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
Teerapat Khunpech
 
Bitbucket
BitbucketBitbucket
Bitbucket
hariprasad1035
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLab
Shinu Suresh
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
Sébastien Saunier
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Elli Kanal
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
SeongJae Park
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Bo-Yi Wu
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
Chris Caple
 
Git training
Git trainingGit training
Git training
adm_exoplatform
 
Gittalk
GittalkGittalk
Gittalk
prtinsley
 
How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee company
Minqi Pan
 
Nebula: Netflix's OSS Gradle Plugins
Nebula: Netflix's OSS Gradle PluginsNebula: Netflix's OSS Gradle Plugins
Nebula: Netflix's OSS Gradle Plugins
Rob Spieldenner
 
Git & SourceTree
Git & SourceTreeGit & SourceTree
Git & SourceTree
Tu Tran
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
Teerapat Khunpech
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLab
Shinu Suresh
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
SeongJae Park
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Bo-Yi Wu
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
Chris Caple
 

Similar to Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017 (20)

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Git basics
Git basicsGit basics
Git basics
Amit Sawhney
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Git
GitGit
Git
Parag Gupta
 
Working with Git
Working with GitWorking with Git
Working with Git
Pete Nicholls
 
Gitflow
GitflowGitflow
Gitflow
Phuoc Bui
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
Tagged Social
 
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
Becky Todd
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git Together
Rakesh Jha
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
Sankar Suda
 
Loading...git
Loading...gitLoading...git
Loading...git
Rafael García
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
Christoph Matthies
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
Wim Godden
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
Jesús Miguel Benito Calzada
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
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
Becky Todd
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git Together
Rakesh Jha
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
Sankar Suda
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
Christoph Matthies
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
Wim Godden
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Ad

More from Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
Codemotion
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
Codemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
Codemotion
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
Codemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Ad

Recently uploaded (20)

How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 

Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017

  • 1. 1 Git on the front line Nicola Iarocci
  • 2. 2 Who Am INicola Iarocci, a weirdo Python by Night I am the author and maintainer of a few Python open source projects: python-eve.org, python-cerberus.organd more. Microsoft MVP MongoDB Master I also happen to be a Microsoft MVP for Visual Studio and Development Technologies and a MongoDB Master. Communities I run DevRomagna, a developers community, and CoderDojo Ravenna, a coding club for kids. http://devromagna.org C# by Day I am the author of Sofware Gestionali Amica, a line of accounting and invoicing applications for Italian small businesses. Check it out at http://gestionaleamica.com
  • 3. 3 one size does not fit all git workflows
  • 4. 4 the main branch where the source code of HEAD always reflects a production-ready state origin/master main branch where HEAD always holds the latest delivered development changes, ready for next release origin/develop feature, release and hotfix branches. these always have a limited life time, since they will be removed eventually supporting branches an elegant mental model well suited for packaged software. Not ideal for frequent release cycles such as those we have in modern web development summary Git Flowa successful git branching model http://nvie.com/posts/a-successful-git-branching-model/
  • 5. 5 the main branch where the source code of HEAD always reflects a production-ready state origin/master to work on something new, create a descriptively named branch off of master branch feature branch when you need feedback or help, or you think the branch is ready for merging, open a pull request pull request & review a lightweight, branch-based workflow that supports teams and projects where deployments are made regularly summary GitHub Flowwidely adopted by the open source community http://scottchacon.com/2011/08/31/github-flow.html
  • 6. 6 Streamline your git experience aliases
  • 7. 7 git status, succinctly $ git st ## work M README.md $ git config —-global alias.st ‘status -sb’
  • 8. 8 show last commit $ git last commit c828339f02f832818f868bbfe457e64bfcc3e64a Author: Nicola Iarocci <[email protected]> Date: Thu Oct 19 10:28:42 2017 +0200 first commit $ git config —-global alias.last ‘log -1 HEAD’
  • 9. 9 quick branch checkout $ git co mybranch switched to branch ‘mybranch’ $ git config —-global alias.co ‘checkout’ Hint: git co - works like cd - but between branches (git checkout - works, too)
  • 10. 10 checkout to a new branch $ git cob newbranch switched to a new branch ‘mybranch’ $ git config —-global alias.cob ‘checkout -b’ branch is created on the fly
  • 11. 11 amend last commit $ git amend <edit commit message> $ git config —-global alias.amend ‘commit —-amend’
  • 12. 12 add staged changes to last commit $ git add . $ git fixup $ git config —-global alias.fixup ‘commit —-amend —-noedit’ skip editing the commit message
  • 13. 13 unstage changes $ git st ## work M README.md $ git unstage README.md Unstaged changes after reset: M README.md $ git config —-global alias.unstage ‘reset HEAD’ pass no filename to unstage all, or use wildcard
  • 14. 14 show staged changes $ git diffc diff —git a/README.md b/README.md index 2fd9bc4..889c3dc 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ TITLE +test $ git config —-global alias.diffc ‘diff —-cached’
  • 15. 15 undo last commit and keep changes $ git r1 Unstaged changes after reset: M README.md $ git config —-global alias.r1 ‘reset HEAD^’ changes are left unstaged
  • 16. 16 undo last commit, discard changes $ git rh1 HEAD is now at c828339 first commit $ git config —-global alias.rh1 ‘reset -—hard HEAD^’ use with caution
  • 17. 17 add all changes including untracked, and commit with message $ git cm “my commit message” [mybranch ea88184] my commit message 1 file changed, 1 insertion(+), 1 deletion(-) !git add -A && git commit -m
  • 18. 18 add all changes excluding untracked, then commit as WIP $ git wip [mybranch ea88184] WIP 1 file changed, 1 insertion(+), 1 deletion(-) !git add -u && git commit -m WIP
  • 19. 19 add all changes including untracked, then commit as SAVEPOINT $ git save [mybranch ea88184] SAVEPOINT 1 file changed, 1 insertion(+), 1 deletion(-) !git add -A && git commit -m SAVEPOINT
  • 20. 20 resume work after WIP or SAVEPOINT $ git undo Unstaged files after reset: M README.md $ git config —-global alias.undo ‘reset HEAD^ —-mixed’ functionally identical to ‘r1’ but makes more sense semantically
  • 21. 21 add changes to commit, then wipe that commit $ git wipe HEAD is now at 8da9860 my commit message $ git reflog 8da9860 HEAD@{0}: reset: moving to HEAD~1 4998619 HEAD@{1}: commit: WIPE SAVEPOINT $ git reset —hard 4998619 HEAD is now at 4998619 WIPE SAVEPOINT !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard now working dir is clean, but I can still go back if need arises (via reflog)
  • 22. 22 hierarchical, git-powered grep $ git g “event hooks” CHANGES 1077:- [new] pre_<method> and ``pre_<method>_<resource>`` event hooks are now docs/features.rst 1216:Database event hooks 1219:Database event hooks work like request event hooks $ git config —-global alias.g ‘grep --break --heading --line-number’ faster than standard grep
  • 23. 23 show a tree with all branches $ git tree * bbde45f (HEAD -> expand_cerberus_registries) WIP * 3a25ea7 (origin/master, master) Merge branch ‘use_ordereddict_from_backport_collections_#1070’ | | * 9fb1a66 Changelog for #1070 | * fa8da19 use OrderedDict from backport_collections |/ * cee2f7e Merge branch 'support_for_decimal_type_#1048' | | * 46af495 Minor changelog fixes for #1048 | * 3bf1930 Support Decimal type MongoDB |/ !git log --graph --decorate --all --oneline which brings us to the next topic…
  • 24. 24 push/unpush current branch to remote $ git publish $ git unpublish In .gitconfig: branch-name = "!git rev-parse --abbrev-ref HEAD" publish = "!git push -u origin $(git branch-name)" unpublish = "!git push origin :$(git branch-name)" and set it to track upstream branch
  • 25. 25 delete branches already merged to master $ git delete-merged-branches Deleted branch add_new_user_gravatar_links Deleted branch assign_unique_key_to_uploads Deleted branch remember_the_last_activity_per_user Deleted branch update_kaminari_to_thread_safe_version “!git branch —-merged master | grep -v '*' | xargs -n 1 git branch -d"
  • 26. 26 shortcut to .config file $ git ec <hack away at your .config file> $ git config —-global alias.ec ‘config —global —e’
  • 28. 28 keep your history clean and consistent rebase Demo a documentation project
  • 29. 29 reuse recorded resolutions to solve hunk conflicts rerere $ git config —-global rerere.enabled true https://git-scm.com/blog/2010/03/08/rerere.html
  • 30. 30 shows all non-common commits in two branches (@antirez) rx script
  • 31. 31 Aliases Streamline your workflow. Don’t Repeat Yourself. Consider sharing with team. Rebase Keep project history clean, compact and consistent. Not as hard as you thought. Keep Learning Study more advanced git features. Consider building your own scripts. Pick a Workflow Don’t be afraid to customize it just to suit your use case, project, and team. You Are a Craftsmansharpen your tools