$30 off During Our Annual Pro Sale. View Details »

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
PRO

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 Slide

  2. Trees
    Snapshots of a directory

    View Slide

  3. Working Directory
    file1
    v1
    file2
    v1
    file3
    v1

    View Slide

  4. $ git init

    View Slide

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

    View Slide

  6. $ 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 Slide

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

    View Slide

  8. $ git add file1

    View Slide

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

    View Slide

  10. $ 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  17. $ 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 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 Slide

  19. 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 Slide

  20. $ echo v2 > file1

    View Slide

  21. 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 Slide

  22. $ 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 Slide

  23. $ git add file1

    View Slide

  24. 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 Slide

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

    View Slide

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

    View 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 Slide

  28. 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 Slide

  29. Reset
    3 ways to move backward

    View Slide

  30. Soft Reset
    Move HEAD

    View Slide

  31. $ git reset --soft HEAD~1

    View 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
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf

    View Slide

  33. 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 Slide

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

    View Slide

  35. $ git undo

    View Slide

  36. Mixed Reset
    Move HEAD and update the index

    View Slide

  37. $ git reset HEAD~1

    View 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
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View Slide

  39. 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 Slide

  40. 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 Slide

  41. $ git reset HEAD

    View Slide

  42. 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 Slide

  43. 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 Slide

  44. $ git reset HEAD -- file1

    View Slide

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

    View Slide

  46. $ git unstage

    View Slide

  47. $ git unstage file1

    View Slide

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

    View Slide

  49. Caution
    Hard reset can cause data loss

    View Slide

  50. $ git reset --hard HEAD~1

    View 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
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View Slide

  52. 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 Slide

  53. 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 Slide

  54. $ git reset --hard HEAD

    View Slide

  55. 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 Slide

  56. 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 Slide

  57. Not recommended
    without saving to the repo first

    View Slide

  58. Stash
    Save work for later

    View Slide

  59. 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 Slide

  60. $ git stash -u

    View Slide

  61. $ git stash save -u 'Description'

    View Slide

  62. 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 Slide

  63. 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 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
    v1
    file1
    v2
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v2
    SHA: d59baaf
    stash@{0}
    file3
    v1
    file2
    v2
    file1
    v3

    View Slide

  65. $ echo v2 > file3

    View 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
    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 Slide

  67. $ git add file3

    View Slide

  68. 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 Slide

  69. $ git commit -m 'Modify file3'

    View Slide

  70. 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 Slide

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

    View Slide

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

    View Slide

  73. $ git stash show stash@{0}

    View Slide

  74. $ git stash pop

    View Slide

  75. 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 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
    v2
    file2
    v2
    file1
    v3
    file2
    v1
    file1
    v2
    file3
    v2
    file1
    v1
    file2
    v1
    file3
    v2
    file1
    v2
    SHA: 04ed46a

    View Slide

  77. $ git stash apply

    View Slide

  78. 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 Slide

  79. 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 Slide

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

    View Slide

  81. Reflog
    A meta repo for your repo

    View 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
    v2
    SHA: d59baaf
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    file2
    v1
    file3
    v1
    file1
    v1
    SHA: cde7f23
    file2
    v1
    file3
    v1

    View Slide

  83. 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 Slide

  84. 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 Slide

  85. $ 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 Slide

  86. $ 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 Slide

  87. $ git reset --hard d59baaf

    View Slide

  88. $ 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 Slide

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

    View Slide

  90. $ git reflog show feature-branch

    View Slide

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

    View Slide

  92. Interactive Rebase
    Rewriting history

    View Slide

  93. $ 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 Slide

  94. Fix before you push
    Force pushing is just rude

    View Slide

  95. $ git rebase -i HEAD~8

    View Slide

  96. 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 Slide

  97. 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 Slide

  98. 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 Slide

  99. 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 Slide

  100. 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 Slide

  101. 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 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
    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 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
    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 Slide

  104. 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 Slide

  105. 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 Slide

  106. 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 Slide

  107. 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 Slide

  108. 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 Slide

  109. 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 Slide

  110. 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 Slide

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

    View Slide

  112. Blame
    Spelunk who and why

    View Slide

  113. WTF?

    View Slide

  114. $ git blame lib/index.js

    View Slide

  115. View Slide

  116. View Slide

  117. $ git show a8fd0459

    View Slide

  118. View Slide

  119. View Slide

  120. OMG!

    View Slide

  121. View Slide

  122. View Slide

  123. TEH PR!

    View Slide

  124. View Slide

  125. Trees
    Snapshots of directories in time

    View Slide

  126. Reset
    Modify HEAD, index, and working directory

    View Slide

  127. Stash
    Save work for later

    View Slide

  128. Reflog
    History of history

    View Slide

  129. Interactive Rebase
    Make yourself seem super organized

    View Slide

  130. Blame
    Find who and, hopefully, why

    View Slide

  131. Questions?

    View Slide

  132. Thank you!
    Git Better
    A talk by orderedlist

    View Slide