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

2,102
-1

Published on

Women Who Code lightening talk, August 21, 2012

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,102
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
16
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • 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

    ×