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

Git: Beyond the Basics

Git: Beyond the Basics

John Bohn

July 10, 2012
Tweet

More Decks by John Bohn

Other Decks in Programming

Transcript

  1. Almost any VCS works does this (more or less) What

    is special about git? Thursday, August 2, 12
  2. Change Blink - Two logical changes - Don’t want to

    bother undoing one - Can’t git add . or git add [file] Thursday, August 2, 12
  3. git add --patch Stage other changes Diff is now empty

    (everything is staged or commited) Thursday, August 2, 12
  4. git stash --no-keep-index git stash --keep-index git stash --patch git

    stash --include-untracked My Favorites Thursday, August 2, 12
  5. git reset --soft [sha] git reset --hard [sha] git reset

    --mixed [sha] Thursday, August 2, 12
  6. Bisecting 7b35b 91296 9680d 2ab1f c6d43 6 Commits - One

    Bug We know that 7b35b is good We know that cfc332 is bad But we have no idea where the bug was introduced cfc332 Thursday, August 2, 12
  7. Bisecting 7b35b 91296 9680d 2ab1f c6d43 Tell git what is

    known good and bad cfc332 good bad Thursday, August 2, 12
  8. Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good

    good 2ab1f is most likely good because the commit after it is Thursday, August 2, 12
  9. git reflog Technically shows any action where the tip of

    a branch is modified git reflog --all shows stashes, bisects, etc. Thursday, August 2, 12
  10. Recovery Let’s say I reset --hard and wiped out the

    commit that changed my LED to pin 10 Use combination of reflog and cherry-pick to get it back Thursday, August 2, 12
  11. Recovery Double check that 3ecdba3 is really the commit we

    want git diff 3ecdba3^.. 3ecdba3 Shows me the difference between the commit I want to cherry pick and the commit prior. Thursday, August 2, 12
  12. git cherry-pick Now cherry pick 3ecdba3 into our working tree

    Note: the sha has changed because this commit now has a different parent than it did when it was recorded into the reflog Thursday, August 2, 12
  13. git internals git stores snapshots, not differences Storing differences is

    slow and inflexible CVS/Subversion git Thursday, August 2, 12
  14. git internals git stores snapshots, not differences Storing differences is

    slow and inflexible CVS/Subversion git Thursday, August 2, 12
  15. git internals Let’s investigate a repo Sorry for the bad

    “investigation” image ;-) Thursday, August 2, 12