Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Cool Git Tricks(That I learn when things go badly.)                                       @cczona
Carina C. Zona     @cczona   www.cczona.com                    @cczona
I write a detailedcommit 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.bashcp	 git-completion.bash	 ~/.git-completion.shecho	 source	 ~/.git-completion.sh	...
$	 git	 checkout	 <tab><tab>0.1-mvp-release	 	 	 	 	 	 	 	 marketing-content-dump2.0-public-release	 	 	 	 	 masterauthent...
$	 git	 checkout	 b<tab>Switched	 to	 branch	 button-to-pay-me
I use ‘git status’       (A lot.)                     @cczona
git/contrib/completion/git-prompt.shcp	 git-prompt.sh	 ~/.git-prompt.shecho	 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/c...
I pathologically avoid    `git	 add	 .`         (Now.)                     @cczona
$	 git	 grep	 -e	 stupid	 	 	 	 	 	 --and	 -e	 bossindex.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...
#	 arbitrary	 commit	 $	 git	 grep“2007”HEAD^#	 range	 $	 git	 grep	 “2007”c0c1e80..141a16a#	 every	 commit$	 git	 grep“20...
I don’t necessarily detect a problem   immediately.   (Time machine needed.)                            @cczona
$	 git	 bisect	 start$	 git	 bisect	 bad	 HEAD$	 git	 bisect	 good	 v2.0Bisecting:	 44	 revisions	 left	 to	 test	 after	 ...
I sometimes need to  pretend a commit   never happened.  (Like, even rebase ain’t gonna cut it.)                          ...
$	 git	 checkout	 HEAD~10...$	 lsabout.htmlcontact.htmluber-secret-never-commit-this.txt
(leaving	 out	 many	 crucial	 details...)filter-branch	 #	 remove	 from	 local	 commits...reflog	 expire	 #	 make	 artifac...
Git can be a pain.It also has cool tricks to take pain away.                (Whew.)                                       ...
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:/...
Upcoming SlideShare
Loading in …5
×

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

8,267 views

Published on

Women Who Code lightening talk, August 21, 2012

Published in: Technology
  • Be the first to comment

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

  1. 1. Cool Git Tricks(That I learn when things go badly.) @cczona
  2. 2. Carina C. Zona @cczona www.cczona.com @cczona
  3. 3. I write a detailedcommit message. (About some other changeset.) @cczona
  4. 4. $ git commit# Changes to be committed:#...# odified: foo.txt m
  5. 5. $ git commit -v# Changes to be committed:#...# odified: foo.txt m#...-old line+new line
  6. 6. I create long branch names. (Then have to type all that.) @cczona
  7. 7. git/contrib/completion/git-completion.bashcp git-completion.bash ~/.git-completion.shecho source ~/.git-completion.sh >> ~/.bashrc
  8. 8. $ git checkout <tab><tab>0.1-mvp-release marketing-content-dump2.0-public-release masterauthentication-basic optimize-for-webkitbutton-to-pay-me redesign-for-fall-2012live-customer-chat ui-performance-enhance
  9. 9. $ git checkout b<tab>Switched to branch button-to-pay-me
  10. 10. I use ‘git status’ (A lot.) @cczona
  11. 11. git/contrib/completion/git-prompt.shcp git-prompt.sh ~/.git-prompt.shecho source ~/.git-completion.sh >> ~/.bashrc
  12. 12. #master|MERGE $#master|REBASE-i $#master + $ # tracked#master $ $ # stash#master> $ # upstream
  13. 13. 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.txt1 pending on foundation#master~/repo/foundation/css $
  14. 14. I pathologically avoid `git add .` (Now.) @cczona
  15. 15. $ git grep -e stupid --and -e bossindex.html: The boss is a stupidhead
  16. 16. $ git grep -e promotion --or -e bargain --not -e (coupon|discount)
  17. 17. # 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
  18. 18. # arbitrary commit $ git grep“2007”HEAD^# range $ git grep “2007”c0c1e80..141a16a# every commit$ git grep“2007”$(git rev-list --all)
  19. 19. I don’t necessarily detect a problem immediately. (Time machine needed.) @cczona
  20. 20. $ git bisect start$ git bisect bad HEAD$ git bisect good v2.0Bisecting: 44 revisions left to test after this (roughly 6 steps)...b047b0 is first bad commit
  21. 21. I sometimes need to pretend a commit never happened. (Like, even rebase ain’t gonna cut it.) @cczona
  22. 22. $ git checkout HEAD~10...$ lsabout.htmlcontact.htmluber-secret-never-commit-this.txt
  23. 23. (leaving out many crucial details...)filter-branch # remove from local commits...reflog expire # make artifacts eligible for garbage collectiongc # do the garbage collectionpush --force # rewrite remote history
  24. 24. Git can be a pain.It also has cool tricks to take pain away. (Whew.) @cczona
  25. 25. Questions? Carina C. Zona www.cczona.com @cczona @cczona
  26. 26. 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

×