SlideShare a Scribd company logo
1 of 77
Download to read offline
NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • • @DURDN
The business case for Git
Concepts and techniques to convert you
into a master of the DVCS craft
Becoming a Git Master
I'm George. George McFly.
I'm your density… I mean,
your destiny
Let’s Become Git Pros!
CONFLICT RESOLUTION TIPS
HIDING STUFF
Here you’ll learn:
POLISH YOUR CODE
PREVENT TAMPERING
PROJECT DEPENDENCIES
PRO ALIASES & PROMPT
A pro command prompt
PRO ALIASES & PROMPT
Everyone has their favorite, but!
Liquid prompt is awesome
http://bit.do/liquid-prompt
PRO ALIASES & PROMPT
Everyone has their favorite, but!
Liquid prompt is awesome
http://bit.do/liquid-prompt
Crafting Awesome Aliases
Aliases are stored in
.gitconfig
In a section prefixed:
[alias]
PRO ALIASES & PROMPT
Basic Alias Form
Very simple:
ls = log --oneline
[vagrant@vagrant-ubuntu-trusty-64:/home/vagrant/buildstep] master ± git ls
90aa814 Merge pull request #85 from marqu3z/master
f1eb16b overwrite source.list
e6b9d16 change repo before prepare task
8bc10c0 Fix for deprecated repository
e34d861 Link to buildpacks.txt instead
4502635 Merge pull request #76 from elia/fix-72-no-buildpack-bundle-install
38be796 Bundle install ain't needed against the buildpack
PRO ALIASES & PROMPT
You can do great things with just this
For example: amend the last commit with
everything I have here uncommitted and new
caa = commit -a --amend -C HEAD
You can’t pass parameters
to simple aliases :(
Or can you?!
muahahhahahhaha
hahahahahahahha
hahahhahahahah!
PRO ALIASES & PROMPT
For multiple commands or complex
parameters use a bash function!
You can escape to a shell with ! like this:
my_alias = "!f() { <command> }; f”
PRO ALIASES & PROMPT
Some useful shortcuts and variables
More in any bash manual
$@ - all command line parameters passed
$1 - first command line parameter
$2 - second command line parameter
Ma, it’s the mini-DSL
I always wanted!
PRO ALIASES & PROMPT
What can you do with this?
Cool cool things, for example add a Bitbucket remote:
git remote add $1 https://bitbucket.org/$2.git;
PRO ALIASES & PROMPT
ra = "!f() { 

}; f"
What can you do with this?
Cool cool things, for example add a Bitbucket remote:
git remote add $1 https://bitbucket.org/$2.git;
PRO ALIASES & PROMPT
ra = "!f() { 

}; f"
What can you do with this?
Cool cool things, for example add a Bitbucket remote:
git remote add $1 https://bitbucket.org/$2.git;
git ra jsmith jsmith/prj
PRO ALIASES & PROMPT
ra = "!f() { 

}; f"
What can you do with this?
Cool cool things, for example add a Bitbucket remote:
git remote add $1 https://bitbucket.org/$2.git;
git ra jsmith jsmith/prj
PRO ALIASES & PROMPT
Get all the alias goodness on Bitbucket
http://bit.do/git-aliases
© http://www.amigosdosbichos.org/
1. Powers of invisibility
© http://www.amigosdosbichos.org/
1. Powers of invisibility
Tell git which files
or folders to ignore
in .gitignore
What if the file is
already committed?!
muahahhahahhaha
hahahahahahahha
hahahhahahahah!
Hide files from
Different from .gitignore, it hides committed files
POWERS OF INVISIBILITY
git update-index --assume-unchanged <file>
very useful with git-svn
Hide files from
Revert it with:
POWERS OF INVISIBILITY
git update-index --no-assume-unchanged <file>
remember to add --no
POWERS OF INVISIBILITY
List assumed unchanged files
git ls-files -v | grep ^h
Useful as alias (see alias list from before)
Conflict Resolution Tips
What is a conflict?
PRO ALIASES & PROMPT
A word on terminology
Current checked
out branch
--ours
What do ours and theirs mean when solving conflicts?
Commit coming in
(i.e. via merge)
--theirs
PRO ALIASES & PROMPT
Basics for easy conflict resolution
The common commands are:
$ git checkout --ours/--theirs <file>
Check back out our own/their own version of the file
$ git add <file>
Add the change to the index will resolve the conflict
PRO ALIASES & PROMPT
Aliases for easy conflict resolution
Add these to [alias] in .gitconfig:
git checkout --ours $@ && git add $@;
PRO ALIASES & PROMPT
Aliases for easy conflict resolution
Add these to [alias] in .gitconfig:
ours = "!f() { 

}; f"
git checkout --ours $@ && git add $@;
PRO ALIASES & PROMPT
rerere resolve!
Reuse Recorded Resolution will help you when
dealing with repetitive and similar merge conflicts.
$ git config --global rerere.enabled true
Turns it on and forget about it
PRO ALIASES & PROMPT
Sample output rerere
$ git add hello.rb
$ git commit
Recorded resolution for 'hello.rb'.
[master 68e16e5] Merge branch 'i18n'
Auto-merging hello.rb
CONFLICT (content): Merge conflict in hello.rb
Resolved 'hello.rb' using previous resolution.
Cover your tracks
(aka polish your code)
POLISH YOUR CODE
What is a rebase?
It’s a way to replay commits, one by one,
on top of a branch
MASTER
FEATURE
POLISH YOUR CODE
What is a rebase?
It’s a way to replay commits, one by one,
on top of a branch
MASTER
FEATURE
POLISH YOUR CODE
What is a rebase?
It’s a way to replay commits, one by one,
on top of a branch
MASTER
FEATURE
Don’t use!
POLISH YOUR CODE
What is a rebase?
Correct way to use rebase to update a
feature branch
MASTER
FEATURE
POLISH YOUR CODE
What is a rebase?
Correct way to use rebase to update a
feature branch
MASTER
FEATURE
POLISH YOUR CODE
What is an --interactive rebase?
It’s a way to replay commits, one by one,
deciding interactively what to do with each
PICK
SQUASH
REWORD
FIXUP
EDIT
EXEC
POLISH YOUR CODE
--autosquash
Automatically modify the todo list of
rebase --interactive by annotating commits
$ git config --global rebase.autosquash true
Turns on the feature
POLISH YOUR CODE
--autosquash
You can prepend commit messages with:
git commit -m “squash! …"
git commit -m “fixup! …"
git commit -m “reword! …"
etc…
Rebase task list will be then prepopulated
CUSTOMARY
WARNING!
rebase rewrites history!
Treat this power with great care. 

Only rewrite history of local branches or…
Prevent tampering
Always a balancing act
Security DevSpeed
PREVENT TAMPERING
Lock down your repo
# no rewriting history
denyNonFastForwards = true
# no deleting history
denyDeletes = true
# check object consistency
fsckObjects = true
Edit .git/config in the [receive] section:
Reject force push,
Git project has already an update hook
‘update-paranoid’ that is designed to
reject history rewriting updates
Luke
http://bit.do/update-paranoid
Reject force push,Luke
Reject force push,Luke
PREVENT TAMPERING
Impersonating Authors is easy
with
$ git commit -m "I'm Luke"
$ git commit --author "Elvis <elvis@graceland.net>" -m "I'm elvis"
commit a9f0967cba236465d6cb68247..
Author: Elvis <elvis@graceland.net>
Date: Mon Apr 22 18:06:35 2013 -0500
I'm Elvis
commit d6eb7572cbb4bdd8e2aaa5c90..
Author: Luke <luke@tatooine.com>
Date: Mon Apr 22 18:04:54 2013 -0500
I'm Luke
PREVENT TAMPERING
Solution: you can sign & verify tags
git tag -s <tag_name> -m “message”
Sign a tag with your GPG key
git tag -v <tag_name>
Verifies that the signature is valid
Signing release tags is often
all you need
PREVENT TAMPERING
Aside on GPG
The GNU Privacy Guard
GnuPG allows to encrypt and sign your data and
communication, features a versatile key management system.
PREVENT TAMPERING
Harden up by signing things
Sample gpg commands to get you started:
gpg --gen-key
Generate your GPG keys
gpg -k
List your keys
gpg -a --export <keyid>
Export your key
PREVENT TAMPERING
Hide files in raw objects
actually writes into the object db
git hash-object -w <file>
Remember to associate a tag to
it or it will be garbage collected
PREVENT TAMPERING
Store your signature in
Simple! Add a tag referencing your public key
gpg -a --export <keyid> | 
git hash-object -w --stdin
Store your public key in a raw object
git tag nicks-key 65704f3…
Tag the raw object with a label
raw object id
PREVENT TAMPERING
Import other public keys
git cat-file -p tims-key | gpg --import
Import a GPG key from a tag
PREVENT TAMPERING
Now you can sign & verify tags
git tag -s <tag_name> -m “message”
Sign a tag with your GPG key
git tag -v <tag_name>
Verifies that the signature is valid
and Project Dependencies
How do you handle
project dependencies
with ?
Splitting up a project
is painful, for so many
reasons
Use a build/dependency
tool instead of
GIT AND PROJECT DEPENDENCIES
I’ll give you an incomplete list of examples!
Java
Nodejs
Javascript
Python Pip easy-install
Ruby
GIT AND PROJECT DEPENDENCIES
I’ll give you an incomplete list of examples! (2)
C#
C++ c-make
Objective C
PHP
Go godep
Another possibility:
use git submodule
Another possibility:
use git subtree
Use other build
and cross-stack
dependency tools
GIT AND PROJECT DEPENDENCIES
•Android Repo (http://bit.do/android-repo)

•Repobuild (chrisvana / repobuild)

•Chromium depot_tools (http://bit.do/depot-tools)

•Facebook Buck (http://facebook.github.io/buck/)

•Twitter Pants (http://bit.do/twitter-pants)
For example you can check out:
PRO ALIASES & PROMPT
Review these ideas online
http://bit.do/git-deps
CONFLICT RESOLUTION TIPS
HIDING STUFF
Today we covered:
POLISH YOUR CODE
PREVENT TAMPERING
PROJECT DEPENDENCIES
PRO ALIASES & PROMPT
NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • ATLASSIAN • @DURDN
Thank you!
Mechelen - 26th November
@durdn

More Related Content

What's hot

Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境謝 宗穎
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsDigitalOcean
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudIdeato
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeSoshi Nemoto
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90minsLarry Cai
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerSematext Group, Inc.
 
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.
 
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondCoreOS
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesLarry Cai
 
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerDocker, Inc.
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Ontico
 
Networking in Kubernetes
Networking in KubernetesNetworking in Kubernetes
Networking in KubernetesMinhan Xia
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a NutshellCoreOS
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionSysdig
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLarry Cai
 

What's hot (20)

Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby Steps
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in Cloud
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on DockerRunning High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
 
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 in practice
Docker in practiceDocker in practice
Docker in practice
 
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Networking in Kubernetes
Networking in KubernetesNetworking in Kubernetes
Networking in Kubernetes
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 

Viewers also liked

Git case of the week4212.
Git case of the week4212.Git case of the week4212.
Git case of the week4212.Shaikhani.
 
A Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenA Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenAtlassian
 
The adoption of FOSS workfows in commercial software development: the case of...
The adoption of FOSS workfows in commercial software development: the case of...The adoption of FOSS workfows in commercial software development: the case of...
The adoption of FOSS workfows in commercial software development: the case of...dmgerman
 
Code Management Workshop
Code Management WorkshopCode Management Workshop
Code Management WorkshopSameh El-Ashry
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciAtlassian
 
Git GIB Variceal lower 2011 .
Git GIB Variceal lower 2011 .Git GIB Variceal lower 2011 .
Git GIB Variceal lower 2011 .Shaikhani.
 
Gastrointestinal Pathology
Gastrointestinal  PathologyGastrointestinal  Pathology
Gastrointestinal PathologyKETAN VAGHOLKAR
 
Pathophysiology of Upper GI Bleeding
Pathophysiology of Upper GI BleedingPathophysiology of Upper GI Bleeding
Pathophysiology of Upper GI Bleedingyellow sunfire
 
Upper Gastrointestinal bleeding
Upper Gastrointestinal bleedingUpper Gastrointestinal bleeding
Upper Gastrointestinal bleedingAmmar L. Aldwaf
 

Viewers also liked (17)

Git case of the week4212.
Git case of the week4212.Git case of the week4212.
Git case of the week4212.
 
A Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenA Business Case for Git - Tim Pettersen
A Business Case for Git - Tim Pettersen
 
Git pavel grushetsky
Git pavel grushetskyGit pavel grushetsky
Git pavel grushetsky
 
The adoption of FOSS workfows in commercial software development: the case of...
The adoption of FOSS workfows in commercial software development: the case of...The adoption of FOSS workfows in commercial software development: the case of...
The adoption of FOSS workfows in commercial software development: the case of...
 
Code Management Workshop
Code Management WorkshopCode Management Workshop
Code Management Workshop
 
Git. Transition.
Git. Transition.Git. Transition.
Git. Transition.
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
 
Git GIB Variceal lower 2011 .
Git GIB Variceal lower 2011 .Git GIB Variceal lower 2011 .
Git GIB Variceal lower 2011 .
 
Gastrointestinal Pathology
Gastrointestinal  PathologyGastrointestinal  Pathology
Gastrointestinal Pathology
 
Pathology of Upper GIT - Quiz
Pathology of Upper GIT - QuizPathology of Upper GIT - Quiz
Pathology of Upper GIT - Quiz
 
Git pathology m scyear2011 12
Git pathology m scyear2011 12Git pathology m scyear2011 12
Git pathology m scyear2011 12
 
Pathology of Upper GIT
Pathology of Upper GITPathology of Upper GIT
Pathology of Upper GIT
 
SCM case study of Marico
SCM case study of MaricoSCM case study of Marico
SCM case study of Marico
 
Pathophysiology of Upper GI Bleeding
Pathophysiology of Upper GI BleedingPathophysiology of Upper GI Bleeding
Pathophysiology of Upper GI Bleeding
 
Upper Gastrointestinal bleeding
Upper Gastrointestinal bleedingUpper Gastrointestinal bleeding
Upper Gastrointestinal bleeding
 
Git from SVN
Git from SVNGit from SVN
Git from SVN
 

Similar to Becoming a Git Master

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
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 controlBecky Todd
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICLa FeWeb
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
VCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopVCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopAnis Ahmad
 
Version Control ThinkVitamin
Version Control ThinkVitaminVersion Control ThinkVitamin
Version Control ThinkVitaminAlex Hillman
 
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentationMack Hardy
 
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 AgainLemi Orhan Ergin
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceForest Mars
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commandsZakaria Bouazza
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 

Similar to Becoming a Git Master (20)

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
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
 
Gittalk
GittalkGittalk
Gittalk
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETIC
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
VCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopVCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT Workshop
 
Git
GitGit
Git
 
Version Control ThinkVitamin
Version Control ThinkVitaminVersion Control ThinkVitamin
Version Control ThinkVitamin
 
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentation
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
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
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
Git basics
Git basicsGit basics
Git basics
 
Loading...git
Loading...gitLoading...git
Loading...git
 

More from Nicola Paolucci

Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git PracticesNicola Paolucci
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementNicola Paolucci
 
Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Nicola Paolucci
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeNicola Paolucci
 
Real World Git Workflows - EclipseCon Europe 2013
Real World Git Workflows - EclipseCon Europe 2013Real World Git Workflows - EclipseCon Europe 2013
Real World Git Workflows - EclipseCon Europe 2013Nicola Paolucci
 

More from Nicola Paolucci (6)

Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git Practices
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
 
Git Power Routines
Git Power RoutinesGit Power Routines
Git Power Routines
 
Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
 
Real World Git Workflows - EclipseCon Europe 2013
Real World Git Workflows - EclipseCon Europe 2013Real World Git Workflows - EclipseCon Europe 2013
Real World Git Workflows - EclipseCon Europe 2013
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Becoming a Git Master

  • 1. NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • • @DURDN The business case for Git Concepts and techniques to convert you into a master of the DVCS craft Becoming a Git Master
  • 2. I'm George. George McFly. I'm your density… I mean, your destiny
  • 4. CONFLICT RESOLUTION TIPS HIDING STUFF Here you’ll learn: POLISH YOUR CODE PREVENT TAMPERING PROJECT DEPENDENCIES PRO ALIASES & PROMPT
  • 5. A pro command prompt
  • 6. PRO ALIASES & PROMPT Everyone has their favorite, but! Liquid prompt is awesome http://bit.do/liquid-prompt
  • 7. PRO ALIASES & PROMPT Everyone has their favorite, but! Liquid prompt is awesome http://bit.do/liquid-prompt
  • 9. Aliases are stored in .gitconfig
  • 10. In a section prefixed: [alias]
  • 11. PRO ALIASES & PROMPT Basic Alias Form Very simple: ls = log --oneline [vagrant@vagrant-ubuntu-trusty-64:/home/vagrant/buildstep] master ± git ls 90aa814 Merge pull request #85 from marqu3z/master f1eb16b overwrite source.list e6b9d16 change repo before prepare task 8bc10c0 Fix for deprecated repository e34d861 Link to buildpacks.txt instead 4502635 Merge pull request #76 from elia/fix-72-no-buildpack-bundle-install 38be796 Bundle install ain't needed against the buildpack
  • 12. PRO ALIASES & PROMPT You can do great things with just this For example: amend the last commit with everything I have here uncommitted and new caa = commit -a --amend -C HEAD
  • 13. You can’t pass parameters to simple aliases :(
  • 16. PRO ALIASES & PROMPT For multiple commands or complex parameters use a bash function! You can escape to a shell with ! like this: my_alias = "!f() { <command> }; f”
  • 17. PRO ALIASES & PROMPT Some useful shortcuts and variables More in any bash manual $@ - all command line parameters passed $1 - first command line parameter $2 - second command line parameter
  • 18. Ma, it’s the mini-DSL I always wanted!
  • 19. PRO ALIASES & PROMPT What can you do with this? Cool cool things, for example add a Bitbucket remote: git remote add $1 https://bitbucket.org/$2.git;
  • 20. PRO ALIASES & PROMPT ra = "!f() { }; f" What can you do with this? Cool cool things, for example add a Bitbucket remote: git remote add $1 https://bitbucket.org/$2.git;
  • 21. PRO ALIASES & PROMPT ra = "!f() { }; f" What can you do with this? Cool cool things, for example add a Bitbucket remote: git remote add $1 https://bitbucket.org/$2.git; git ra jsmith jsmith/prj
  • 22. PRO ALIASES & PROMPT ra = "!f() { }; f" What can you do with this? Cool cool things, for example add a Bitbucket remote: git remote add $1 https://bitbucket.org/$2.git; git ra jsmith jsmith/prj
  • 23. PRO ALIASES & PROMPT Get all the alias goodness on Bitbucket http://bit.do/git-aliases
  • 26. Tell git which files or folders to ignore in .gitignore
  • 27. What if the file is already committed?!
  • 29. Hide files from Different from .gitignore, it hides committed files POWERS OF INVISIBILITY git update-index --assume-unchanged <file> very useful with git-svn
  • 30. Hide files from Revert it with: POWERS OF INVISIBILITY git update-index --no-assume-unchanged <file> remember to add --no
  • 31. POWERS OF INVISIBILITY List assumed unchanged files git ls-files -v | grep ^h Useful as alias (see alias list from before)
  • 33. What is a conflict?
  • 34. PRO ALIASES & PROMPT A word on terminology Current checked out branch --ours What do ours and theirs mean when solving conflicts? Commit coming in (i.e. via merge) --theirs
  • 35. PRO ALIASES & PROMPT Basics for easy conflict resolution The common commands are: $ git checkout --ours/--theirs <file> Check back out our own/their own version of the file $ git add <file> Add the change to the index will resolve the conflict
  • 36. PRO ALIASES & PROMPT Aliases for easy conflict resolution Add these to [alias] in .gitconfig: git checkout --ours $@ && git add $@;
  • 37. PRO ALIASES & PROMPT Aliases for easy conflict resolution Add these to [alias] in .gitconfig: ours = "!f() { }; f" git checkout --ours $@ && git add $@;
  • 38. PRO ALIASES & PROMPT rerere resolve! Reuse Recorded Resolution will help you when dealing with repetitive and similar merge conflicts. $ git config --global rerere.enabled true Turns it on and forget about it
  • 39. PRO ALIASES & PROMPT Sample output rerere $ git add hello.rb $ git commit Recorded resolution for 'hello.rb'. [master 68e16e5] Merge branch 'i18n' Auto-merging hello.rb CONFLICT (content): Merge conflict in hello.rb Resolved 'hello.rb' using previous resolution.
  • 40. Cover your tracks (aka polish your code)
  • 41. POLISH YOUR CODE What is a rebase? It’s a way to replay commits, one by one, on top of a branch MASTER FEATURE
  • 42. POLISH YOUR CODE What is a rebase? It’s a way to replay commits, one by one, on top of a branch MASTER FEATURE
  • 43. POLISH YOUR CODE What is a rebase? It’s a way to replay commits, one by one, on top of a branch MASTER FEATURE Don’t use!
  • 44. POLISH YOUR CODE What is a rebase? Correct way to use rebase to update a feature branch MASTER FEATURE
  • 45. POLISH YOUR CODE What is a rebase? Correct way to use rebase to update a feature branch MASTER FEATURE
  • 46. POLISH YOUR CODE What is an --interactive rebase? It’s a way to replay commits, one by one, deciding interactively what to do with each PICK SQUASH REWORD FIXUP EDIT EXEC
  • 47. POLISH YOUR CODE --autosquash Automatically modify the todo list of rebase --interactive by annotating commits $ git config --global rebase.autosquash true Turns on the feature
  • 48. POLISH YOUR CODE --autosquash You can prepend commit messages with: git commit -m “squash! …" git commit -m “fixup! …" git commit -m “reword! …" etc… Rebase task list will be then prepopulated
  • 49. CUSTOMARY WARNING! rebase rewrites history! Treat this power with great care. Only rewrite history of local branches or…
  • 51. Always a balancing act Security DevSpeed
  • 52. PREVENT TAMPERING Lock down your repo # no rewriting history denyNonFastForwards = true # no deleting history denyDeletes = true # check object consistency fsckObjects = true Edit .git/config in the [receive] section:
  • 53. Reject force push, Git project has already an update hook ‘update-paranoid’ that is designed to reject history rewriting updates Luke http://bit.do/update-paranoid
  • 56. PREVENT TAMPERING Impersonating Authors is easy with $ git commit -m "I'm Luke" $ git commit --author "Elvis <elvis@graceland.net>" -m "I'm elvis" commit a9f0967cba236465d6cb68247.. Author: Elvis <elvis@graceland.net> Date: Mon Apr 22 18:06:35 2013 -0500 I'm Elvis commit d6eb7572cbb4bdd8e2aaa5c90.. Author: Luke <luke@tatooine.com> Date: Mon Apr 22 18:04:54 2013 -0500 I'm Luke
  • 57. PREVENT TAMPERING Solution: you can sign & verify tags git tag -s <tag_name> -m “message” Sign a tag with your GPG key git tag -v <tag_name> Verifies that the signature is valid
  • 58. Signing release tags is often all you need
  • 59. PREVENT TAMPERING Aside on GPG The GNU Privacy Guard GnuPG allows to encrypt and sign your data and communication, features a versatile key management system.
  • 60. PREVENT TAMPERING Harden up by signing things Sample gpg commands to get you started: gpg --gen-key Generate your GPG keys gpg -k List your keys gpg -a --export <keyid> Export your key
  • 61. PREVENT TAMPERING Hide files in raw objects actually writes into the object db git hash-object -w <file> Remember to associate a tag to it or it will be garbage collected
  • 62. PREVENT TAMPERING Store your signature in Simple! Add a tag referencing your public key gpg -a --export <keyid> | git hash-object -w --stdin Store your public key in a raw object git tag nicks-key 65704f3… Tag the raw object with a label raw object id
  • 63. PREVENT TAMPERING Import other public keys git cat-file -p tims-key | gpg --import Import a GPG key from a tag
  • 64. PREVENT TAMPERING Now you can sign & verify tags git tag -s <tag_name> -m “message” Sign a tag with your GPG key git tag -v <tag_name> Verifies that the signature is valid
  • 66. How do you handle project dependencies with ?
  • 67. Splitting up a project is painful, for so many reasons
  • 69. GIT AND PROJECT DEPENDENCIES I’ll give you an incomplete list of examples! Java Nodejs Javascript Python Pip easy-install Ruby
  • 70. GIT AND PROJECT DEPENDENCIES I’ll give you an incomplete list of examples! (2) C# C++ c-make Objective C PHP Go godep
  • 73. Use other build and cross-stack dependency tools
  • 74. GIT AND PROJECT DEPENDENCIES •Android Repo (http://bit.do/android-repo) •Repobuild (chrisvana / repobuild) •Chromium depot_tools (http://bit.do/depot-tools) •Facebook Buck (http://facebook.github.io/buck/) •Twitter Pants (http://bit.do/twitter-pants) For example you can check out:
  • 75. PRO ALIASES & PROMPT Review these ideas online http://bit.do/git-deps
  • 76. CONFLICT RESOLUTION TIPS HIDING STUFF Today we covered: POLISH YOUR CODE PREVENT TAMPERING PROJECT DEPENDENCIES PRO ALIASES & PROMPT
  • 77. NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • ATLASSIAN • @DURDN Thank you! Mechelen - 26th November @durdn