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

Git and GitHub Secrets

Git and GitHub Secrets

This talk covers both Git and GitHub: different tricks I've picked up after two years at GitHub, helpful advice on common gripes I've seen in support tickets and tweets, and just general nifty things that make you a faster, more capable technologist.

http://zachholman.com/talk/git-github-secrets

Zach Holman

May 22, 2012
Tweet

More Decks by Zach Holman

Other Decks in Programming

Transcript

  1. GIT&GITHUB&SECRETS

    View full-size slide

  2. NO
    FORKING
    HOLMAN
    @
    LOST
    YO QUIT READING THIS SHIT

    View full-size slide

  3. I AM DEFINITELY
    NOT A SMART GUY

    View full-size slide

  4. LUCKILY I HANG
    AROUND THIS CREW A LOT

    View full-size slide

  5. THIS IS MOSTLY
    WHAT GETS DISCUSSED

    View full-size slide

  6. BUT SOMETIMES ALSO GIT THINGS

    View full-size slide

  7. LEMME THROW A BUNCH
    AT YOU ALL AT ONCE

    View full-size slide

  8. SOMETIMES
    FEATURES
    DON’T MAKE
    IT INTO THE UI

    View full-size slide

  9. HIDDEN HTML
    DIFF TOOLS
    EMAIL HACKS
    DEEP LINKING
    CLEVER APIS
    MEANING OF LIFE

    View full-size slide

  10. EXPERIMENTATION

    View full-size slide

  11. I’d use this all the time!
    But Holman,

    WHY DON’T YOU JUST ADD A BUTTON?
    You ass.”

    View full-size slide

  12. lemme mock that up for u

    View full-size slide

  13. aim for simplicity
    BUT STAY FLEXIBLE

    View full-size slide

  14. .DIFF & .PATCH

    View full-size slide

  15. ADD OR TO URLS:
    .DIFF .PATCH
    COMPARE VIEWS
    PULL REQUESTS
    COMMIT PAGES
    .DIFF & .PATCH

    View full-size slide

  16. IGNORE WHITESPACE
    ADD TO ANY DIFF URL
    ?w=1

    View full-size slide

  17. SUBVERSION
    EVERY GIT REPOSITORY
    SVN REPOSITORY
    is also a

    View full-size slide

  18. SUBVERSION
    SVN/GIT SERVICE LAYER

    View full-size slide

  19. SUBVERSION
    SVN CALLS
    TRANSLATE INTO
    GIT CALLS ON OUR SERVERS

    View full-size slide

  20. SUBVERSION
    SVN CHECKOUT GITHUB.COM/HOLMAN/BOOM

    View full-size slide

  21. HTTP & SSH
    ZOMG SNEAKY
    STEALTH CHANGES

    View full-size slide

  22. HTTP & SSH
    PREVIOUSLY

    View full-size slide

  23. HTTP & SSH
    NEW HOTNESS

    View full-size slide

  24. HTTP & SSH
    WE USE SMART HTTP
    (EFFICIENT SERVERSIDE PACKFILE GENERATION)

    View full-size slide

  25. HTTP & SSH
    WE USE SMART HTTP
    (EFFICIENT SERVERSIDE PACKFILE GENERATION)
    CORPORATE FIREWALLS
    (OH NUTS)

    View full-size slide

  26. HTTP & SSH
    WE USE SMART HTTP
    (EFFICIENT SERVERSIDE PACKFILE GENERATION)
    CORPORATE FIREWALLS
    (OH NUTS)
    NO KEY GENERATION
    (WINDOWS, NON-NECKBEARDS)

    View full-size slide

  27. HTTP & SSH
    LOLWAT I DONT CARE

    View full-size slide

  28. HTTP & SSH
    › git push origin master
    Username for 'github.com':
    FUUUUUUUUUUUUUUUUU

    View full-size slide

  29. HTTP & SSH
    CREDENTIAL CACHING IN GIT 1.7.9
    HELP.GITHUB.COM/ARTICLES/SET-UP-GIT
    (INSTALLED BY HOMEBREW)

    View full-size slide

  30. HTTP & SSH
    STICKY SELECTOR
    CLICK THIS,
    GITHUB REMEMBERS

    View full-size slide

  31. GIT CLONE HTTPS://GITHUB.COM/HOLMAN/BOOM
    CLONING WITHOUT .GIT
    GIT CLONE HTTPS://GITHUB.COM/HOLMAN/BOOM.GIT

    View full-size slide

  32. GITHUB HD™
    WITH OUR NEW ICON SET, WE’RE
    SUPER-ZOOMABLE
    (⌘++ on a Mac or pinch on iOS)

    View full-size slide

  33. GITHUB HD™

    View full-size slide

  34. GITHUB HD™

    View full-size slide

  35. GITHUB HD™

    View full-size slide

  36. GITHUB HD™

    View full-size slide

  37. AUDITING
    PUBLIC KEYS
    GITHUB.COM/SETTINGS/SECURITY
    REPOSITORIES
    ·

    View full-size slide

  38. OCTOCAT
    CHEAP
    ISTOCKPHOTO
    ILLUSTRATION FOR
    OUR ERROR PAGE

    View full-size slide

  39. OCTOCAT
    THEN PEOPLE
    LIKED HIM

    View full-size slide

  40. OCTOCAT
    BECAME SORT OF A
    GITHUB MASCOT

    View full-size slide

  41. OCTOCAT
    HOLY CRAP WE
    SHOULD GET
    EXCLUSIVE RIGHTS

    View full-size slide

  42. OCTOCAT
    DOZENS OF OCTOCATS
    OCTODEX.GITHUB.COM

    View full-size slide

  43. GIT.IO
    GITHUB.COM URL SHORTENER

    View full-size slide

  44. GIT.IO
    git.io/nxVVig
    SHELL SCRIPT

    View full-size slide

  45. GIT.IO
    › gitio
    USAGE
    http://git.io/nxVVig

    View full-size slide

  46. LINGUIST
    LANGUAGE
    detection
    syntax highlighting
    vendored files

    View full-size slide

  47. LINGUIST
    GITHUB.COM/GITHUB/LINGUIST
    OPEN SOURCE AT:

    View full-size slide

  48. EMAIL REPLIES
    REPLY TO AN EMAIL! SRSLY!

    View full-size slide

  49. ABUSING GIST

    View full-size slide

  50. ABUSING GIST
    AIN’T JUST FOR SNIPPETS

    View full-size slide

  51. @NRRRDCORE
    Julie Horvath
    ABUSING GIST
    DESIGNERS

    View full-size slide

  52. ABUSING GIST
    DESIGNERS

    View full-size slide

  53. ABUSING GIST
    DESIGNERS
    PROTOTYPING TOOL
    COMMENTS
    SCREENSHOTS
    CODE

    View full-size slide

  54. ABUSING GIST
    DEVELOPERS

    View full-size slide

  55. ABUSING GIST
    DEVELOPERS
    GISTS ARE FULL REPOS

    View full-size slide

  56. jeffkreeftmeijer.com/2011/microgems-five-minute-rubygems
    ABUSING GIST
    DEVELOPERS
    MICROGEMS

    View full-size slide

  57. aka GEM IN A GIST
    INCLUDE A GEMSPEC IN YOUR GIST
    ABUSING GIST
    DEVELOPERS

    View full-size slide

  58. gem 'test-spec-mini',
    :git => 'git://gist.github.com/1806986.git'
    GEMFILE
    ABUSING GIST
    DEVELOPERS

    View full-size slide

  59. git.io/mini
    EXAMPLE
    ABUSING GIST
    DEVELOPERS

    View full-size slide

  60. ABUSING GIST
    DEVELOPERS
    QUICK,
    DISPOSABLE
    PROJECTS

    View full-size slide

  61. IMAGE VIEW MODES
    COMPARE IMAGE REVISIONS

    View full-size slide

  62. IMAGE VIEW MODES
    SWIPE TO SEE DIFFERENCES

    View full-size slide

  63. IMAGE VIEW MODES
    SWIPE TO SEE DIFFERENCES

    View full-size slide

  64. HUB
    COMMAND LINE GITHUB

    View full-size slide

  65. HUB
    brew install hub
    INSTALL

    View full-size slide

  66. HUB
    hub clone holman/boom
    FANCY CLONING

    View full-size slide

  67. HUB
    hub push origin,staging
    MULTI-REMOTE PUSHES

    View full-size slide

  68. HUB
    hub pull-request -i
    ATTACH A PULL REQUEST TO AN ISSUE

    View full-size slide

  69. HUB
    alias git=hub
    ALIASING FTW

    View full-size slide

  70. HUB
    GITHUB.COM/DEFUNKT/HUB
    OPEN SOURCE AT:

    View full-size slide

  71. ACCELEROMETERS!

    View full-size slide

  72. KEYBOARD SHORTCUTS
    tFILE FINDER

    View full-size slide

  73. KEYBOARD SHORTCUTS

    View full-size slide

  74. KEYBOARD SHORTCUTS
    w
    BRANCH SELECTOR

    View full-size slide

  75. KEYBOARD SHORTCUTS

    View full-size slide

  76. KEYBOARD SHORTCUTS
    SQUICK SEARCH

    View full-size slide

  77. KEYBOARD SHORTCUTS
    ?ALL COMMANDS

    View full-size slide

  78. SUBSCRIBING PEOPLES
    MOST OF
    OUR ISSUES
    END WITH
    MENTIONS

    View full-size slide

  79. SUBSCRIBING PEOPLES
    MENTIONED USERS
    GET SUBSCRIBED TO
    ALL SUBSEQUENT
    NOTIFICATIONS

    View full-size slide

  80. SUBSCRIBING PEOPLES
    ALSO MENTION
    TEAMS DIRECTLY
    @ORG/TEAM

    View full-size slide

  81. AUTOLINKED SHAS
    GITHUB FLAVORED MARKDOWN
    MENTION SHA, WE AUTOLINK

    View full-size slide

  82. AUTOLINKED CROSS-REPO SHAS
    GITHUB FLAVORED MARKDOWN
    USER@SHA1 USER/REPO@SHA1

    View full-size slide

  83. AUTOLINKED CROSS-REPO ISSUES
    GITHUB FLAVORED MARKDOWN
    #1 USER#1
    · USER/REPO#1
    ·

    View full-size slide

  84. FENCED CODE HIGHLIGHTING
    ```ruby
    require 'redcarpet'
    markdown = Redcarpet.new("Hello World!")
    puts markdown.to_html
    ```
    SPECIFY YOUR LANGUAGE
    GITHUB FLAVORED MARKDOWN

    View full-size slide

  85. FENCED CODE HIGHLIGHTING
    require 'redcarpet'
    markdown = Redcarpet.new("Hello World!")
    puts markdown.to_html
    RENDERED README OUTPUT
    GITHUB FLAVORED MARKDOWN

    View full-size slide

  86. AUTO-CLOSING ISSUES
    CLOSES/CLOSED/CLOSE #1
    FIXES/FIXED/FIX #1

    View full-size slide

  87. COMMITS BY AUTHOR
    github.com/play/play/commits/master
    REPOSITORY COMMITS

    View full-size slide

  88. COMMITS BY AUTHOR
    ?author=holman
    AUTHOR QUERY PARAM

    View full-size slide

  89. BRANCH-TO-BRANCH
    PULL REQUESTS
    PULLS NEEDN’T
    BE FROM A FORK

    View full-size slide

  90. BRANCH-TO-BRANCH
    PULL REQUESTS
    WE ONLY WORK
    OFF BRANCHES

    View full-size slide

  91. BRANCH-TO-BRANCH
    PULL REQUESTS
    SIMPLE PERMISSIONS
    SIMPLE GIT COMMANDS

    View full-size slide

  92. USE SCREENSHOTS
    PULL REQUESTS
    MARKDOWN
    ![title](http://example.com/image.png)

    View full-size slide

  93. CONVERT ISSUE TO PULL
    PULL REQUESTS
    POST /repos/:user/:repo/pulls
    {
    "issue": "5",
    "head": "octocat:new-feature",
    "base": "master"
    }

    View full-size slide

  94. EMOJI!
    EMOJI-CHEAT-SHEET.COM
    SHIPIT +1 -1 RAGE2 SHIT
    HEART FIRE
    :EMOJI:

    View full-size slide

  95. LINE LINKING
    CLICK A LINE ADDS #L16 TO URL

    View full-size slide

  96. LINE LINKING
    ALSO ACCEPTS RANGES #L16-25

    View full-size slide

  97. ADVANCED COMPARE VIEW
    github.com/user/repo/compare/{range}
    {RANGE} = MASTER...MY-BRANCH

    View full-size slide

  98. ADVANCED COMPARE VIEW
    {RANGE} IS SMART

    View full-size slide

  99. ADVANCED COMPARE VIEW
    MASTER@{1.day.ago}...MASTER

    View full-size slide

  100. ADVANCED COMPARE VIEW
    MASTER@{yesterday}...MASTER

    View full-size slide

  101. ADVANCED COMPARE VIEW
    MASTER@{2012-02-25}...MASTER

    View full-size slide

  102. COMMITLESS COMMITS
    --allow-empty

    View full-size slide

  103. COMMITLESS COMMITS
    › git commit \
    -m “LOOK AT ME TROLOLOL” \
    --allow-empty
    [master 1a3fbce] LOOK AT ME TROLOLOL

    View full-size slide

  104. STAGING HUNKS
    diff --git a/README.md b/README.md
    index e69de29..a224a77 100644
    --- a/README.md
    +++ b/README.md
    @@ -0,0 +1,5 @@
    +# THE README
    +
    +## A quality story by @holman
    Stage this hunk [y,n,q,a,d,/,e,?]?
    git add -p

    View full-size slide

  105. STAGING HUNKS
    Stage this hunk [y,n,q,a,d,/,e,?]? ?
    y - stage this hunk
    n - do not stage this hunk
    q - quit; do not stage this hunk nor any of the remaining ones
    a - stage this hunk and all later hunks in the file
    d - do not stage this hunk nor any of the later hunks in the file
    g - select a hunk to go to
    / - search for a hunk matching the given regex
    j - leave this hunk undecided, see next undecided hunk
    J - leave this hunk undecided, see next hunk
    k - leave this hunk undecided, see previous undecided hunk
    K - leave this hunk undecided, see previous hunk
    s - split the current hunk into smaller hunks
    e - manually edit the current hunk
    ? - print help
    git add -p

    View full-size slide

  106. STAGING HUNKS
    git add -p
    SMALL, LOGICAL COMMIT SETS

    View full-size slide

  107. LAST MATCHED COMMIT SEARCH
    git show :/query

    View full-size slide

  108. LAST MATCHED COMMIT SEARCH
    › git show :/stupid
    commit 76f4b2b15722d05c7acf7ec12b3ea98d6fb4c213
    Author: Aman Gupta
    Date: Fri Apr 27 16:34:55 2012 -0700
    stupid hacks around rails Logger monkey patching

    View full-size slide

  109. GO BACK
    › git checkout -
    Switched to branch 'master'
    › git checkout -
    Switched to branch 'master'
    › git checkout -
    Switched to branch 'next'
    › cd -

    View full-size slide

  110. MERGED BRANCHES
    › git branch --merged
    * master
    change_email
    auth

    View full-size slide

  111. MERGED BRANCHES
    › git branch --no-merged
    date-fix
    test-speed

    View full-size slide

  112. MERGED BRANCHES
    › git branch --contains 838ad46
    date-fix

    View full-size slide

  113. CONTENT COPY
    › git checkout BRANCH -- path/to/file.rb
    COPIES file.rb AT BRANCH
    WITHOUT SWITCHING BRANCHES

    View full-size slide

  114. REACHABLE COMMITS
    › git log branchA ^branchB
    COMMITS IN A THAT AREN’T IN B

    View full-size slide

  115. FINDING LOST COMMITS
    › git fsck −−lost-found
    dangling blob 517b8fc32153761aadc15a96947911938f809a28
    dangling commit e4fb392355bf37db17f2f601ca68a208a7c16a1d
    dangling commit f53b6771ed929896eca1149e741084930262b9fb
    dangling blob 61bd82962fc470543b17ce6adee37c184cae63cf
    dangling commit 9cbd3ff21acbd8673259969efaa0a9762fe75046
    ...

    View full-size slide

  116. DIFFSTATS
    › git diff HEAD^ --stat
    README.md | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    View full-size slide

  117. BLAME
    › git blame
    ^b649495 (Zach Holman 1) class User
    ^b649495 (Zach Holman 2) def name
    c8c05b6e (Zach Holman 3) 'Foucault'
    ^b649495 (Zach Holman 4) end
    ^b649495 (Zach Holman 5) end

    View full-size slide

  118. BLAME
    › git blame
    ^b649495 (Zach Holman 1) class User
    ^b649495 (Zach Holman 2) def name
    c8c05b6e (Zach Holman 3) 'Foucault'
    ^b649495 (Zach Holman 4) end
    ^b649495 (Zach Holman 5) end

    View full-size slide

  119. BLAME
    › git blame -w
    ^b649495 (Zach Holman 1) class User
    ^b649495 (Zach Holman 2) def name
    ^b649495 (Zach Holman 3) 'Foucault'
    ^b649495 (Zach Holman 4) end
    ^b649495 (Zach Holman 5) end
    IGNORE WHITESPACE

    View full-size slide

  120. BLAME
    › git blame -M
    A
    B
    DETECT MOVES

    View full-size slide

  121. BLAME
    › git blame -M
    B
    A
    DETECT MOVES

    View full-size slide

  122. BLAME
    › git blame -M
    DETECT MOVES
    BLAMES ORIGINAL COMMIT,
    NOT THE MOVE COMMIT

    View full-size slide

  123. BLAME
    › git blame -C
    DETECT MOVES OVER FILES
    LIKE -M, BUT LOOKS AT OTHER
    FILES IN THAT SAME COMMIT

    View full-size slide

  124. BLAME
    › git blame -CC
    DETECT MOVES OVER FILES
    ALSO LOOKS AT THE COMMIT
    THE FILE WAS CREATED IN

    View full-size slide

  125. BLAME
    › git blame -CCC
    DETECT MOVES OVER FILES
    ALSO LOOKS AT ALL COMMITS

    View full-size slide

  126. MULTI-REMOTE FETCHES
    › git config remotes.mygroup 'remote1 remote2'
    › git fetch mygroup

    View full-size slide

  127. A BETTER STATUS
    › git status
    › git status
    # On branch master
    # Changes not staged for commit:
    # (use "git add <file>..." to update what will be committed)
    # (use "git checkout -- <file>..." to discard changes in working directory)
    #
    # modified: README.md
    #
    no changes added to commit (use "git add" and/or "git commit -a")

    View full-size slide

  128. A BETTER STATUS
    › git status -sb
    ## master
    M README.md

    View full-size slide

  129. WORD DIFFING
    › git diff HEAD^
    index 37ebc1b..2589f44 100644
    --- a/README.md
    +++ b/README.md
    @@ -1,3 +1,3 @@
    # This is a repository
    -There are many like it, but this one is mine.
    +There are many like it, but this one is prolly mine.

    View full-size slide

  130. WORD DIFFING
    › git diff HEAD^ --word-diff
    index 37ebc1b..2589f44 100644
    --- a/README.md
    +++ b/README.md
    @@ -1,3 +1,3 @@
    # This is a repository
    There are many like it, but this one is {+prolly+} mine.

    View full-size slide

  131. CONFIG: SPELLING
    › git comit
    git: 'comit' is not a git command. See 'git --help'.
    Did you mean this?
    commit

    View full-size slide

  132. CONFIG: SPELLING
    › git comit
    WARNING: You called a Git command named 'comit', which does not exist.
    Continuing under the assumption that you meant 'commit'
    in 0.1 seconds automatically...
    › git config --global help.autocorrect 1

    View full-size slide

  133. CONFIG: GIT RERERE
    › git config --global rerere.enabled 1
    REUSE RECORDED RESOLUTION
    REMEMBERS AND RECORDS
    MERGE CONFLICTS
    LONG-RUNNING BRANCHES

    View full-size slide

  134. CONFIG: COLOR!
    › git config --global color.ui 1

    View full-size slide

  135. ALIAS: GIT-AMEND
    › git commit --amend -C HEAD
    › git-amend

    View full-size slide

  136. ALIAS: GIT-UNDO
    › git reset --soft HEAD^
    (RETAINS COMMIT AS STAGED)

    View full-size slide

  137. ALIAS: GIT-COUNT
    › git shortlog -sn
    500 Zach Holman
    42 Jon Maddox
    29 Jason Costello
    18 Joey Wendt
    17 Aman Gupta
    13 Michael Edwards
    10 Ben Bleikamp
    9 medwards
    6 Paul Betts
    5 Tom Bell
    ...

    View full-size slide

  138. SCRIPT: GIT-CREDIT
    › git commit --amend --author "$1 <$2>" -C HEAD
    › git credit "Zach Holman" [email protected]
    SETS HEAD’S AUTHOR
    AS SOMEONE ELSE

    View full-size slide

  139. Also,
    AN OCTOCAT:
    4 LEGS
    1 TAIL

    View full-size slide

  140. THANKS&THANKS

    View full-size slide

  141. ZACHHOLMAN
    ZACHHOLMAN.COM/TALKS
    @HOLMAN

    View full-size slide