Doctor Gitlove

68da6fcedf72fee45fdd633c50d7e1e7?s=47 globaldev
November 28, 2013

Doctor Gitlove

...or: How I Learned to Stop Worrying and Love Git Rebase

In this talk Paul Bowsher gives some insight into how Git works under-the-hood, so next time you find yourself in some horrible rebase state it's not so scary; you know where it's actually stuck. He explores the different types of object used within git's database and how they all link together to form your git history.

Find the video of the talk at http://vimeo.com/80789852

68da6fcedf72fee45fdd633c50d7e1e7?s=128

globaldev

November 28, 2013
Tweet

Transcript

  1. Doctor Gitlove Or how I learned to stop worrying and

    love git rebase
  2. What is Git? • Distributed Object Database • Used for

    Versioned Source Control
  3. Git SVN • Own local repository • SHA commit refs

    • Commit to local • Push to remote • Branches are references • master • Central repository • Sequential commit #s • Commit to remote ! • Branches are directories • trunk
  4. Working copy Files on your filesystem

  5. Working copy Files on your filesystem

  6. Index Staged changes for your next commit

  7. Index Staged changes for your next commit

  8. Repository Committed changes

  9. Repository Committed changes

  10. Stash Temporary pseudo-commit

  11. Stash Temporary pseudo-commit

  12. Stash Temporary pseudo-commit

  13. Stash Temporary pseudo-commit

  14. Stash Temporary pseudo-commit

  15. Objects • Referred to by SHA-1 of their contents •

    Blob • Tree • Commit • Tag • Immutable
  16. Blobs Every file added to the index is stored as

    a blob
  17. Blobs Blobs can be anywhere in the tree

  18. Blobs Deleting files doesn’t automatically remove the blob

  19. Trees Store location of blob within working copy Store directory

    structure
  20. Trees Inherently versioned

  21. Commits Pointers to a tree and parent commit

  22. Commits Pointers to a tree and parent commit http://xkcd.com/1296/

  23. Tags “Immutable” pointers to commits

  24. Refs Not objects, just shorthand pointers

  25. git push git fetch • Synchronises object database • blobs,

    trees, commits, tags • Synchronises remote references • fetch namespaces: origin/master • push fast-forwards •git push --tags
  26. Push Uploads missing objects Fast-forwards remote refs

  27. Fetch Downloads missing objects Doesn’t touch local refs or working

    copy
  28. Merge New commit with two parents

  29. Merge New commit with two parents

  30. Rebase Reset local to remote, replay your commits

  31. Rebase Reset local to remote, replay your commits

  32. Reset Point your ref at a different commit

  33. Reset Point your ref at a different commit

  34. Reset •--hard • Resets all including working copy •--mixed (default)

    • Resets all excluding working copy •--soft (git commit --amend) • Resets commit only
  35. Pull Some of the above

  36. git up $ gem install git-up 1. Stash 2. Fetch

    3. Rebase all branches 4. Unstash
  37. Feature Branches

  38. Integration Branches

  39. Rebasing Integration Branches

  40. Rebase versus Merge • Rebase • Deal with merge conflicts

    for each commit that gets replayed • Cleaner history • Requires a force-push, replacing history • Merge • One big merge conflict • Many merge commits into your branch
  41. Common gitfalls

  42. Collaborator has force- pushed your branch

  43. Collaborator has force- pushed your branch • Don’t rebase if

    your collaborator is still working directly on the branch • Rebase of feature branch onto integration branch is still easy*
  44. Rebased then pulled

  45. Rebased then pulled

  46. Resources Atlassian Git tutorial - https://www.atlassian.com/git/tutorial Try Git - https://try.github.io

    PeepCode Git Internals PDF - https://github.com/pluralsight/git- internals-pdf/releases Pro Git book - http://git-scm.com/book Git website - http://git-scm.com/