Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ten Things You Didn't Know Git And GitHub Could Do

Ten Things You Didn't Know Git And GitHub Could Do

Git and GitHub are powerful tools. Even if you have worked with them for a long time, it’s likely that you haven’t stumbled across everything yet. I collect 10 common tricks for both Git and GitHub that potentially increase your day-to-day productivity.

41740fef48f778383596392a6b2276c8?s=128

Jingwen Owen Ou

January 18, 2013
Tweet

Transcript

  1. Ten Things You Didn't Know Git And GitHub Could Do

    Owen Ou @JingwenOwenOu http://owenou.com/2012/01/13/ten-things-you-didnt- know-git-and-github-could-do.html Saturday, 19 January, 13
  2. Agenda • 10 GitHub tricks • Demo of GitHub tricks

    • 10 Git tricks • Demo of Git tricks with pull request Saturday, 19 January, 13
  3. Ten GitHub Tricks http://octodex.github.com/front-end-conftocat Saturday, 19 January, 13

  4. t: file finder Saturday, 19 January, 13

  5. w: branch filter Saturday, 19 January, 13

  6. ?: list of shortcuts Saturday, 19 January, 13

  7. whitespace: ?w=1 Saturday, 19 January, 13

  8. commits by range • github.com/user/repo/compare/{range} • range = sha1...sha2 or

    master...my-branch • time can be considered: master@{time}...master • e.g. master@{2012-01-01}...master Saturday, 19 January, 13
  9. commits by range https://github.com/rails/rails/compare/ master@{1.day.ago}...master Saturday, 19 January, 13

  10. commits by author • github.com/user/repo/commits/branch • appending param ?author=github_handle Saturday,

    19 January, 13
  11. commits by author https://github.com/dynjs/dynjs/commits/ master?author=jingweno Saturday, 19 January, 13

  12. .diff & .patch • Add .diff or .patch to the

    URLs of compare view, pull request or commit page • diff or patch in text format • e.g., easy for building tools Saturday, 19 January, 13
  13. .diff & .patch https://github.com/rails/rails/compare/ master@{1.day.ago}...master.patch Saturday, 19 January, 13

  14. email reply Saturday, 19 January, 13

  15. line linking • any file view • click one line

    or multiple lines by pressing SHIFT • good for sharing link to a chunk of code Saturday, 19 January, 13
  16. line linking https://github.com/jingweno/dotfiles/blob/ master/.gitconfig#L5-L9 Saturday, 19 January, 13

  17. subscribing peoples Mentioning users in pull requests, issues or any

    comment will subscribe them to all subsequent notifications Saturday, 19 January, 13
  18. autolink • In pull requests, issues or any comment, sha

    and issue number will be automatically linked • link sha or issue number from another repository with the format of user/ repo@sha1 or user/repo#1 • e.g. rails/rails#1 Saturday, 19 January, 13
  19. autolink Saturday, 19 January, 13

  20. hub • command line GitHub • brew install hub or

    gem install hub • hub pull-request • https://github.com/defunkt/hub Saturday, 19 January, 13
  21. Demo: GitHub Tricks • shortcuts: t, w, ? • ignoring

    whitespace: https://github.com/dynjs/dynjs/commit/ 45ec2e9c08ad10fc28c7a6c3016ef2eab158e20e • commits by range: https://github.com/acl-services/accounts/compare/ master@{yesterday}...master • commits by author: https://github.com/dynjs/dynjs/commits/master? author=jingweno • line linking: https://github.com/acl-services/devise-acl/blob/master/Gemfile Saturday, 19 January, 13
  22. Ten Git Tricks Saturday, 19 January, 13

  23. git log -p FILE Saturday, 19 January, 13

  24. git log -S'PATTERN' Saturday, 19 January, 13

  25. git add -p Saturday, 19 January, 13

  26. git rm --cached FILE Saturday, 19 January, 13

  27. git log ..BRANCH Saturday, 19 January, 13

  28. git branch --merged & git branch --no-merged Saturday, 19 January,

    13
  29. git branch --contains SHA Saturday, 19 January, 13

  30. git status -s Saturday, 19 January, 13

  31. git reflog Saturday, 19 January, 13

  32. git shortlog -sn Saturday, 19 January, 13

  33. Create Shortcuts! Saturday, 19 January, 13

  34. Demo: Git Tricks with Pull Request • Fix the README

    of devise-acl • gem install omglog • hub pull-request • rebase vs. merge vs. merge --no-ff Saturday, 19 January, 13
  35. References • http://owenou.com/2012/01/13/ten-things-you-didnt-know-git-and-github- could-do.html • ProGit: http://git-scm.com/book • Advanced Git

    serials by Peepcode: https://peepcode.com/products/ advanced-git • Git and GitHub Secrets talk by Zach Holman: http://zachholman.com/talk/ git-github-secrets • GitFlow: http://nvie.com/posts/a-successful-git-branching-model Saturday, 19 January, 13
  36. Q & A http://octodex.github.com/gangnamtocat.md Saturday, 19 January, 13