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

Git Better

Git Better

Are you a Git user who feels like they’re only using a fraction of the functionality? Do you find yourself knowing there’s more to it, but are worried about screwing up your repo? In this session we’ll dive into a few of the more powerful commands that will make us better, more confident, more organized developers. Come out of the talk understanding more about the way Git stores your data, how to recover from mistakes, and how to dive more deeply into the information stored in your repository.

Alases gisted at https://gist.github.com/orderedlist/4bc1bb427e949bc728fb

Steve Smith

June 23, 2015
Tweet

More Decks by Steve Smith

Other Decks in Programming

Transcript

  1. Git Better
    Becoming a more skillful collaborator
    A talk by orderedlist

    View full-size slide

  2. Trees
    Snapshots of a directory

    View full-size slide

  3. Working Directory
    file1
    v1
    file2
    v1
    file3
    v1

    View full-size slide

  4. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    HEAD → master

    View full-size slide

  5. $ git status
    On branch master
    Initial commit
    Untracked files:
    (use "git add ..." to include in what will be committed)
    file1
    file2
    file3
    nothing added to commit but untracked files present (use "git
    add" to track)

    View full-size slide

  6. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    HEAD → master
    Unstaged Diff Staged Diff

    View full-size slide

  7. $ git add file1

    View full-size slide

  8. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master

    View full-size slide

  9. $ git status
    On branch master
    Initial commit
    Changes to be committed:
    (use "git rm --cached ..." to unstage)
    new file: file1
    Untracked files:
    (use "git add ..." to include in what will be committed)
    file2
    file3

    View full-size slide

  10. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    Unstaged Diff Staged Diff

    View full-size slide

  11. $ git commit -m "Initial commit"
    [master (root-commit) e327139] Initial commit
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 file1

    View full-size slide

  12. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    e327139

    View full-size slide

  13. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    e327139

    View full-size slide

  14. $ git add file2 file3
    On branch master
    Changes to be committed:
    (use "git reset HEAD ..." to unstage)
    new file: file2
    new file: file3

    View full-size slide

  15. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1

    View full-size slide

  16. $ git commit -m "Adding files"
    [master cde7f23] Adding files
    2 files changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 file2
    create mode 100644 file3

    View full-size slide

  17. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  18. Working Directory Index
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  19. $ echo v2 > file1

    View full-size slide

  20. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  21. $ git status
    On branch master
    Changes not staged for commit:
    (use "git add ..." to update what will be committed)
    (use "git checkout -- ..." to discard changes in working
    directory)
    modified: file1
    no changes added to commit (use "git add" and/or "git commit -a")

    View full-size slide

  22. $ git add file1

    View full-size slide

  23. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v2

    View full-size slide

  24. $ git status
    On branch master
    Changes to be committed:
    (use "git reset HEAD ..." to unstage)
    modified: file1

    View full-size slide

  25. $ git commit -m "Modify file1"
    [master d59baaf] Modify file1
    1 file changed, 1 insertion(+)

    View full-size slide

  26. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View full-size slide

  27. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file1
    v1
    SHA: e327139
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View full-size slide

  28. Reset
    3 ways to move backward

    View full-size slide

  29. Soft Reset
    Move HEAD

    View full-size slide

  30. $ git reset --soft HEAD~1

    View full-size slide

  31. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View full-size slide

  32. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v2

    View full-size slide

  33. $ git config --global alias.undo 'reset --soft HEAD~1'

    View full-size slide

  34. Mixed Reset
    Move HEAD and update the index

    View full-size slide

  35. $ git reset HEAD~1

    View full-size slide

  36. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  37. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  38. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  39. $ git reset HEAD

    View full-size slide

  40. Working Directory Index
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v2
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v3
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file2
    v2
    file1
    v3

    View full-size slide

  41. Working Directory Index
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v2
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v3
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file2
    v2
    file1
    v3

    View full-size slide

  42. $ git reset HEAD -- file1

    View full-size slide

  43. $ git config --global alias.unstage 'reset HEAD --'

    View full-size slide

  44. $ git unstage

    View full-size slide

  45. $ git unstage file1

    View full-size slide

  46. Hard Reset
    Move HEAD, update the index and working directory

    View full-size slide

  47. Caution
    Hard reset can cause data loss

    View full-size slide

  48. $ git reset --hard HEAD~1

    View full-size slide

  49. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  50. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  51. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  52. $ git reset --hard HEAD

    View full-size slide

  53. Working Directory Index
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View full-size slide

  54. Working Directory Index
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file2
    v2
    file1
    v3
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View full-size slide

  55. Not recommended
    without saving to the repo first

    View full-size slide

  56. Stash
    Save work for later

    View full-size slide

  57. Working Directory Index
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file2
    v2
    file1
    v3

    View full-size slide

  58. $ git stash -u

    View full-size slide

  59. $ git stash save -u 'Description'

    View full-size slide

  60. Working Directory Index HEAD → master
    file1
    v1
    SHA: e327139
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  61. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    SHA: e327139
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v1
    file2
    v2
    file1
    v3
    stash@{0}

    View full-size slide

  62. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    SHA: e327139
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    stash@{0}
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  63. $ echo v2 > file3

    View full-size slide

  64. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    SHA: e327139
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    stash@{0}
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  65. $ git add file3

    View full-size slide

  66. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    SHA: e327139
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    stash@{0}
    file2
    v1
    file1
    v2
    file3
    v2
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  67. $ git commit -m 'Modify file3'

    View full-size slide

  68. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    stash@{0}
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  69. $ git stash list
    stash@{0}: WIP on master: d59baaf Modify file1

    View full-size slide

  70. $ git stash show
    file1 | 2 +-
    file2 | 1 +
    2 files changed, 2 insertions(+), 1 deletion(-)

    View full-size slide

  71. $ git stash show stash@{0}

    View full-size slide

  72. $ git stash pop

    View full-size slide

  73. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v1
    file2
    v2
    file1
    v3
    stash@{0}
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a

    View full-size slide

  74. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v2
    file2
    v2
    file1
    v3
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a

    View full-size slide

  75. $ git stash apply

    View full-size slide

  76. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v1
    file2
    v2
    file1
    v3
    stash@{0}
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a
    file3
    v1
    file2
    v2
    file1
    v3

    View full-size slide

  77. file3
    v1
    file1
    v1
    file2
    v2
    file3
    v1
    file1
    v2
    file2
    v2
    file1
    v3
    Working Directory Index HEAD → master
    file1
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file3
    v1
    file2
    v2
    file1
    v3
    stash@{0}
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a
    file3
    v2
    file2
    v2
    file1
    v3

    View full-size slide

  78. $ git stash branch new-branch-name stash@{0}

    View full-size slide

  79. Reflog
    A meta repo for your repo

    View full-size slide

  80. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  81. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  82. Working Directory Index
    file1
    v2
    file2
    v1
    file3
    v1
    file1
    v1
    HEAD → master
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: e327139
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View full-size slide

  83. $ git log
    commit cde7f23cb3d8a3de59b7042e21ea04953d4f3ea3
    Author: Steve Smith
    Date: Fri Jun 19 21:41:43 2015 -0400
    Adding files
    commit e327139d70d9a07ddcca0a83833f113ecffb6780
    Author: Steve Smith
    Date: Fri Jun 19 21:05:00 2015 -0400
    Initial commit

    View full-size slide

  84. $ git reflog
    cde7f23 HEAD@{0}: reset: moving to HEAD~
    d59baaf HEAD@{1}: commit: Modify file1
    cde7f23 HEAD@{2}: commit: Adding files
    e327139 HEAD@{3}: commit (initial): Initial commit

    View full-size slide

  85. $ git reset --hard d59baaf

    View full-size slide

  86. $ git log
    commit d59baafe0279d67a527ee095d0022d8a44aa0017
    Author: Steve Smith
    Date: Sat Jun 20 10:08:21 2015 -0400
    Modify file1
    commit cde7f23cb3d8a3de59b7042e21ea04953d4f3ea3
    Author: Steve Smith
    Date: Fri Jun 19 21:41:43 2015 -0400
    Adding files
    commit e327139d70d9a07ddcca0a83833f113ecffb6780
    Author: Steve Smith
    Date: Fri Jun 19 21:05:00 2015 -0400
    Initial commit

    View full-size slide

  87. $ git checkout -b new-branch-name d59baaf

    View full-size slide

  88. $ git reflog show feature-branch

    View full-size slide

  89. $ git reflog show master@{1.week.ago}

    View full-size slide

  90. Interactive Rebase
    Rewriting history

    View full-size slide

  91. $ git log
    98e64d6 Fix display bug Fixes #145
    cac9ec3 Update comparison text
    23c925b Actually Fix display bug Fixes
    d210f51 I hate display bugs
    ada9e45 Better markup for container
    19181bd /khanify display bugs
    aca26af F$#*&%*!!!
    575c779 I am dumb

    View full-size slide

  92. Fix before you push
    Force pushing is just rude

    View full-size slide

  93. $ git rebase -i HEAD~8

    View full-size slide

  94. pick 98e64d6 Fix display bug Fixes #145
    pick cac9ec3 Update comparison text
    pick 23c925b Actually Fix display bug Fixes
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  95. pick 98e64d6 Fix display bug Fixes #145
    pick cac9ec3 Update comparison text
    pick 23c925b Actually Fix display bug Fixes
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  96. pick 98e64d6 Fix display bug Fixes #145
    r cac9ec3 Update comparison text
    pick 23c925b Actually Fix display bug Fixes
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  97. pick 98e64d6 Fix display bug Fixes #145
    r cac9ec3 Update comparison text
    pick 23c925b Actually Fix display bug Fixes
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  98. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    r cac9ec3 Update comparison text
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  99. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    r cac9ec3 Update comparison text
    pick d210f51 I hate display bugs
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  100. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    f d210f51 I hate display bugs
    r cac9ec3 Update comparison text
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  101. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    f d210f51 I hate display bugs
    r cac9ec3 Update comparison text
    pick ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  102. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    f d210f51 I hate display bugs
    r cac9ec3 Update comparison text
    r ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  103. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    f d210f51 I hate display bugs
    r cac9ec3 Update comparison text
    r ada9e45 Better markup for container
    pick 19181bd /khanify display bugs
    pick aca26af F$#*&%*!!!
    pick 575c779 I am dumb
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  104. pick 98e64d6 Fix display bug Fixes #145
    f 23c925b Actually Fix display bug Fixes
    f d210f51 I hate display bugs
    f 19181bd /khanify display bugs
    f aca26af F$#*&%*!!!
    f 575c779 I am dumb
    r cac9ec3 Update comparison text
    r ada9e45 Better markup for container
    # Rebase a3464a3..33854e7 onto a3464a3 ( 2 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell
    #
    # These lines can be re-ordered; they are executed from top to bottom.
    #
    # If you remove a line here THAT COMMIT WILL BE LOST.
    #
    # However, if you remove everything, the rebase will be aborted.

    View full-size slide

  105. Update comparison text
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # Date: Fri Jun 19 21:41:43 2015 -0400
    #
    # rebase in progress; onto e327139
    # You are currently editing a commit while rebasing branch 'master' on
    'e327139'.
    #
    # Changes to be committed:
    # modified: index.html
    #

    View full-size slide

  106. Update comparison text Fixes #174
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # Date: Fri Jun 19 21:41:43 2015 -0400
    #
    # rebase in progress; onto e327139
    # You are currently editing a commit while rebasing branch 'master' on
    'e327139'.
    #
    # Changes to be committed:
    # modified: index.html
    #

    View full-size slide

  107. Better markup for container
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # Date: Fri Jun 19 21:41:43 2015 -0400
    #
    # rebase in progress; onto e327139
    # You are currently editing a commit while rebasing branch 'master' on
    '83833f1'.
    #
    # Changes to be committed:
    # modified: index.html
    # modified: styles/stylesheet.css
    #

    View full-size slide

  108. Better markup for container Fixes #166
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # Date: Fri Jun 19 21:41:43 2015 -0400
    #
    # rebase in progress; onto e327139
    # You are currently editing a commit while rebasing branch 'master' on
    '83833f1'.
    #
    # Changes to be committed:
    # modified: index.html
    # modified: styles/stylesheet.css
    #

    View full-size slide

  109. $ git log
    e327139 Fix display bug Fixes #145
    83833f1 Update comparison text Fixes #174
    7e03c29 Better markup for container Fixes #166

    View full-size slide

  110. Blame
    Spelunk who and why

    View full-size slide

  111. $ git blame lib/index.js

    View full-size slide

  112. $ git show a8fd0459

    View full-size slide

  113. Trees
    Snapshots of directories in time

    View full-size slide

  114. Reset
    Modify HEAD, index, and working directory

    View full-size slide

  115. Stash
    Save work for later

    View full-size slide

  116. Reflog
    History of history

    View full-size slide

  117. Interactive Rebase
    Make yourself seem super organized

    View full-size slide

  118. Blame
    Find who and, hopefully, why

    View full-size slide

  119. Thank you!
    Git Better
    A talk by orderedlist

    View full-size slide