SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Git branching model_for_tap_team
Git branching model_for_tap_teamGit branching model_for_tap_team
Git branching model_for_tap_team
Grzegorz Wilczynski
 
Thread介紹
Thread介紹Thread介紹
Thread介紹
Jack Chen
 
An Introduction to JavaScript: Week 5
An Introduction to JavaScript: Week 5An Introduction to JavaScript: Week 5
An Introduction to JavaScript: Week 5
Event Handler
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
Lin Yo-An
 

Tendances (20)

Groovy
GroovyGroovy
Groovy
 
Beware sharp tools
Beware sharp toolsBeware sharp tools
Beware sharp tools
 
Linear queue
Linear queueLinear queue
Linear queue
 
Andrey Listochkin "Everybody stand back! I know regular expressions"
Andrey Listochkin "Everybody stand back! I know regular expressions"Andrey Listochkin "Everybody stand back! I know regular expressions"
Andrey Listochkin "Everybody stand back! I know regular expressions"
 
Git branching model_for_tap_team
Git branching model_for_tap_teamGit branching model_for_tap_team
Git branching model_for_tap_team
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Thread介紹
Thread介紹Thread介紹
Thread介紹
 
Xstartup
XstartupXstartup
Xstartup
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
An Introduction to JavaScript: Week 5
An Introduction to JavaScript: Week 5An Introduction to JavaScript: Week 5
An Introduction to JavaScript: Week 5
 
BeautifulSoup / selenium Deep dive
BeautifulSoup / selenium Deep diveBeautifulSoup / selenium Deep dive
BeautifulSoup / selenium Deep dive
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話
 
私の開発環境
私の開発環境私の開発環境
私の開発環境
 
Gitkata fish shell
Gitkata fish shellGitkata fish shell
Gitkata fish shell
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
STACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LISTSTACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LIST
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
Collaborative Coding: Git + Github (NSI Tech Talks)
Collaborative Coding: Git + Github (NSI Tech Talks)Collaborative Coding: Git + Github (NSI Tech Talks)
Collaborative Coding: Git + Github (NSI Tech Talks)
 

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

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 

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

Git
GitGit
Git
 
Loading...git
Loading...gitLoading...git
Loading...git
 
T3dd10 git
T3dd10 gitT3dd10 git
T3dd10 git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git basics
Git basicsGit basics
Git basics
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
 
Git
GitGit
Git
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
 
simple Git
simple Git simple Git
simple Git
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 

Plus de Carina C. Zona

Consequences of an Insightful Algorithm
Consequences of an Insightful AlgorithmConsequences of an Insightful Algorithm
Consequences of an Insightful Algorithm
Carina C. Zona
 
Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three
 Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three
Converged Cloud Computing That's Secure, Fast, or Cheap: Pick Three
Carina C. Zona
 

Plus de Carina C. Zona (11)

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

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

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

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n