SlideShare a Scribd company logo
Cool Git Tricks
(That I learn when things go badly.)




                                       @cczona
Carina C. Zona
     @cczona
   www.cczona.com




                    @cczona
I write a detailed
commit message.
 (About some other changeset.)




                                 @cczona
$	 git	 commit

#	 Changes	 to	 be	 committed:
#...
#	  odified:	 	 	 foo.txt
  m
$	 git	 commit	 -v

#	 Changes	 to	 be	 committed:
#...
#	  odified:	 	 	 foo.txt
  m
#...
-old	 line
+new	 line
I create long branch
       names.
    (Then have to type all that.)




                                    @cczona
git/contrib/completion/
git-completion.bash

cp	 git-completion.bash	 ~/.git-completion.sh

echo	 source	 ~/.git-completion.sh	 >>	 ~/.bashrc
$	 git	 checkout	 <tab><tab>
0.1-mvp-release	 	 	 	 	 	 	 	 marketing-content-dump
2.0-public-release	 	 	 	 	 master
authentication-basic	 	 	 optimize-for-webkit
button-to-pay-me	 	 	 	 	 	 	 redesign-for-fall-2012
live-customer-chat	 	 	 	 	 ui-performance-enhance
$	 git	 checkout	 b<tab>
Switched	 to	 branch	 'button-to-pay-me'
I use ‘git status’
       (A lot.)




                     @cczona
git/contrib/completion/
git-prompt.sh

cp	 git-prompt.sh	 ~/.git-prompt.sh

echo	 source	 ~/.git-completion.sh	 >>	 ~/.bashrc
#master|MERGE	 $
#master|REBASE-i	 $
#master	 +	 $	 #	 tracked
#master	 $	 $	 #	 stash
#master>	 $	 #	 upstream
3	 pending	 on	 foundation#master
~/repo/foundation/css	 $	 git	 add	 .
3	 pending	 on	 foundation#master
~/repo/foundation/css	 $	 git	 commit
...
0	 pending	 on	 foundation#master
~/repo/foundation/css	 $	 touch	 new.txt
1	 pending	 on	 foundation#master
~/repo/foundation/css	 $
I pathologically avoid
    `git	 add	 .`
         (Now.)




                     @cczona
$	 git	 grep	 -e	 stupid	 
	 	 	 	 	 --and	 -e	 boss
index.html:	 The	 boss	 is	 a	 stupidhead
$	 git	 grep	 -e	 promotion	 
	 	 	 	 	 --or	 -e	 bargain	 
	 	 	 	 	 --not	 -e	 (coupon|discount)
#	 working	 area	 tracked
$	 git	 grep

#	 working	 area	 tracked	 &	 untracked
$	 git	 grep	 --untracked

#	 working	 area	 all	 (ignore	 .gitignore)
$	 git	 grep	 --untracked	 --no-exclude-standard

#	 staged
$	 git	 grep	 --cached
#	 arbitrary	 commit	 
$	 git	 grep“2007”HEAD^

#	 range	 
$	 git	 grep	 “2007”c0c1e80..141a16a

#	 every	 commit
$	 git	 grep“2007”$(git	 rev-list	 --all)
I don’t necessarily
 detect a problem
   immediately.
   (Time machine needed.)




                            @cczona
$	 git	 bisect	 start
$	 git	 bisect	 bad	 HEAD
$	 git	 bisect	 good	 v2.0

Bisecting:	 44	 revisions	 
left	 to	 test	 after	 this	 
(roughly	 6	 steps)
...
b047b0	 is	 first	 bad	 commit
I sometimes need to
  pretend a commit
   never happened.
  (Like, even rebase ain’t gonna cut it.)




                                            @cczona
$	 git	 checkout	 HEAD~10
...
$	 ls
about.html
contact.html
uber-secret-never-commit-this.txt
(leaving	 out	 many	 crucial	 details...)
filter-branch	 #	 remove	 from	 local	 
commits...
reflog	 expire	 #	 make	 artifacts	 
eligible	 for	 garbage	 collection
gc	 #	 do	 the	 garbage	 collection
push	 --force	 	 #	 rewrite	 remote	 
history
Git can be a pain.
It also has cool tricks to take pain away.

                (Whew.)




                                             @cczona
Questions?
  Carina C. Zona
 www.cczona.com
    @cczona




                   @cczona
Learn More
• http://git-scm.com/book
• http://blog.bitfluent.com/post/27983389/git-
  utilities-you-cant-live-without

• https://help.github.com/articles/remove-
  sensitive-data

                                             @cczona

More Related Content

What's hot (20)

PDF
Beware sharp tools
AgileOnTheBeach
 
PDF
Linear queue
Er. Ganesh Ram Suwal
 
PDF
Andrey Listochkin "Everybody stand back! I know regular expressions"
Fwdays
 
PDF
Git branching model_for_tap_team
Grzegorz Wilczynski
 
PDF
Doubly Linked List
Er. Ganesh Ram Suwal
 
PPT
Thread介紹
Jack Chen
 
TXT
Xstartup
Ahmed Abdelazim
 
PDF
Git avançado
Jean Carlo Machado
 
PDF
Git walkthrough
Mahmoud Said
 
PDF
An Introduction to JavaScript: Week 5
Event Handler
 
PDF
BeautifulSoup / selenium Deep dive
Naoto MATSUMOTO
 
PDF
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
 
PPTX
私の開発環境
幸雄 村上
 
PDF
Gitkata fish shell
Mateusz Grzechociński
 
PPTX
Introduction to GIT
Arpit Mohan
 
PDF
STACK IMPLEMENTATION USING SINGLY LINKED LIST
Er. Ganesh Ram Suwal
 
PDF
Vim Hacks (OSSF)
Lin Yo-An
 
PPTX
Working in Team using Git in Unity
Rifauddin Tsalitsy
 
PDF
Collaborative Coding: Git + Github (NSI Tech Talks)
Hugo Lopes Tavares
 
Beware sharp tools
AgileOnTheBeach
 
Linear queue
Er. Ganesh Ram Suwal
 
Andrey Listochkin "Everybody stand back! I know regular expressions"
Fwdays
 
Git branching model_for_tap_team
Grzegorz Wilczynski
 
Doubly Linked List
Er. Ganesh Ram Suwal
 
Thread介紹
Jack Chen
 
Xstartup
Ahmed Abdelazim
 
Git avançado
Jean Carlo Machado
 
Git walkthrough
Mahmoud Said
 
An Introduction to JavaScript: Week 5
Event Handler
 
BeautifulSoup / selenium Deep dive
Naoto MATSUMOTO
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
 
私の開発環境
幸雄 村上
 
Gitkata fish shell
Mateusz Grzechociński
 
Introduction to GIT
Arpit Mohan
 
STACK IMPLEMENTATION USING SINGLY LINKED LIST
Er. Ganesh Ram Suwal
 
Vim Hacks (OSSF)
Lin Yo-An
 
Working in Team using Git in Unity
Rifauddin Tsalitsy
 
Collaborative Coding: Git + Github (NSI Tech Talks)
Hugo Lopes Tavares
 

Similar to Cool Git Tricks (That I Learn When Things Go Badly) [1/2] (20)

PPTX
Git
Parag Gupta
 
PDF
Loading...git
Rafael García
 
PDF
T3dd10 git
jugglefish
 
PDF
Wokshop de Git
Alberto Leal
 
PDF
Git - Get Ready To Use It
Daniel Kummer
 
KEY
Git Distributed Version Control System
Victor Wong
 
PDF
Git basics
Amit Sawhney
 
PDF
Git Started With Git
Nick Quaranto
 
KEY
Git Magic: Versioning Files like a Boss
tmacwilliam
 
PPTX
Jedi Mind Tricks for Git
Jan Krag
 
PDF
GTFO: Git Theory For OpenSource
Forest Mars
 
PDF
Git and github 101
Senthilkumar Gopal
 
KEY
Working with Git
Pete Nicholls
 
PDF
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Codemotion
 
PDF
Jedi Mind Tricks in Git
Johan Abildskov
 
PDF
Git Aliases of the Gods!
Atlassian
 
PPTX
simple Git
Caesar Chi
 
PDF
Presentacion git
Ignacio Martín
 
PPTX
Get Good With Git
Hoffman Lab
 
Loading...git
Rafael García
 
T3dd10 git
jugglefish
 
Wokshop de Git
Alberto Leal
 
Git - Get Ready To Use It
Daniel Kummer
 
Git Distributed Version Control System
Victor Wong
 
Git basics
Amit Sawhney
 
Git Started With Git
Nick Quaranto
 
Git Magic: Versioning Files like a Boss
tmacwilliam
 
Jedi Mind Tricks for Git
Jan Krag
 
GTFO: Git Theory For OpenSource
Forest Mars
 
Git and github 101
Senthilkumar Gopal
 
Working with Git
Pete Nicholls
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Codemotion
 
Jedi Mind Tricks in Git
Johan Abildskov
 
Git Aliases of the Gods!
Atlassian
 
simple Git
Caesar Chi
 
Presentacion git
Ignacio Martín
 
Get Good With Git
Hoffman Lab
 

More from Carina C. Zona (11)

PDF
Biometric unsecurity
Carina C. Zona
 
PDF
Consequences of an Insightful Algorithm
Carina C. Zona
 
PDF
Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three
Carina C. Zona
 
PDF
Doctor, Lawyer, Poker Player, Physicist: The Best Engineers We're Not Competi...
Carina C. Zona
 
PDF
Debugging Tech’s Socioeconomic Class Issues [Madison+ Ruby Conf 2014]
Carina C. Zona
 
PDF
What Is ZeroVM
Carina C. Zona
 
PDF
Schemas for the Real World [Software Craftsmanship North America 2013]
Carina C. Zona
 
PDF
Schemas for the Real World [Madison RubyConf 2013]
Carina C. Zona
 
PDF
Schemas for the Real World [RubyConf AU 2013]
Carina C. Zona
 
PDF
Full Stack & Full Circle: What the Heck Happens In an HTTP Request-Response C...
Carina C. Zona
 
KEY
Hacking for Sex Education
Carina C. Zona
 
Biometric unsecurity
Carina C. Zona
 
Consequences of an Insightful Algorithm
Carina C. Zona
 
Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three
Carina C. Zona
 
Doctor, Lawyer, Poker Player, Physicist: The Best Engineers We're Not Competi...
Carina C. Zona
 
Debugging Tech’s Socioeconomic Class Issues [Madison+ Ruby Conf 2014]
Carina C. Zona
 
What Is ZeroVM
Carina C. Zona
 
Schemas for the Real World [Software Craftsmanship North America 2013]
Carina C. Zona
 
Schemas for the Real World [Madison RubyConf 2013]
Carina C. Zona
 
Schemas for the Real World [RubyConf AU 2013]
Carina C. Zona
 
Full Stack & Full Circle: What the Heck Happens In an HTTP Request-Response C...
Carina C. Zona
 
Hacking for Sex Education
Carina C. Zona
 

Recently uploaded (20)

PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Python basic programing language for automation
DanialHabibi2
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 

Cool Git Tricks (That I Learn When Things Go Badly) [1/2]

Editor's Notes