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

Gitting Things Done

Gitting Things Done

Presented on September 21 2022 at the PHP Laravel meetup, Eindhoven, The Netherlands.
https://www.meetup.com/php-laravel-eindhoven/events/288262013/
---------------------------------------------------------------
Git is the modern-day version management system of choice. We all know how to commit, push, pull and merge. But what about (interactive) rebasing, fixing up commits, cherry picking lines and bisecting the history?
And what are those atomic commits you keep hearing people talk about and why would they be of any use to you?

Come and learn how to get the most out of the tooling you already use every day, find ways to make life easier on the people who review your code and leave knowing how to create a clean commit history which is a joy to peruse.
---------------------------------------------------------------

Juliette Reinders Folmer

September 21, 2022
Tweet

More Decks by Juliette Reinders Folmer

Other Decks in Programming

Transcript

  1. Gitting Things Done
    Juliette Reinders Folmer
    Tweet about it: @jrf_nl

    View full-size slide

  2. What is
    Git ?
    Linnaea Mallette

    View full-size slide

  3. About Forks & Remotes

    View full-size slide


  4. There is no one truth
    kconnors

    View full-size slide

  5. Original Repo Fork A Fork B

    View full-size slide

  6. Original Repo Fork A Fork B

    View full-size slide

  7. Original Repo Fork A Fork B

    View full-size slide

  8. Original Repo Fork A Fork B

    View full-size slide


  9. There is no limit to the amount
    of remotes you can add
    or that can exist

    View full-size slide

  10. Pull
    I accept your truth as my truth

    View full-size slide

  11. Push
    My truth is now your truth

    View full-size slide

  12. Pull Request
    Will you accept my truth
    as your truth ?

    View full-size slide

  13. Merging a PR
    Thanks for asking.
    I accept your truth as my truth

    View full-size slide

  14. About
    Branches
    Paul de Bruin

    View full-size slide

  15. Branches are your
    Save Points

    View full-size slide

  16. COPY/DEL
    TEMP
    PR
    WAIT-FOR
    WIP
    TODO
    Use Branches Liberally

    View full-size slide

  17. How to Write
    History and Get
    Your PRs Accepted

    View full-size slide

  18. Decypherable ?

    View full-size slide


  19. A clean history requires
    forethought and discipline
    kconnors

    View full-size slide

  20. Atomic Commits
    Pass CI
    Easy to Review
    Focus on
    One Thing
    Self-contained

    View full-size slide

  21. Atomic Commits
    ===
    Story Telling

    View full-size slide

  22. Tools of The Trade
    ▪ Amend
    Steve Buissinne

    View full-size slide

  23. Tools of The Trade
    ▪ Amend
    ▪ Interactive Rebase
    Maria Yan

    View full-size slide

  24. Interactive Rebase

    View full-size slide

  25. Interactive Rebase

    View full-size slide

  26. squash
    pick
    fixup
    drop
    edit
    reword
    Interactive Rebase

    View full-size slide

  27. Squash vs Fixup
    ▪ Combines changes
    into one commit
    ▪ Combines the
    commit messages +
    presents for edit
    ▪ Combines changes
    into one commit
    ▪ Throws away all but
    the original commit
    message

    View full-size slide

  28. About Commit
    Messages
    ▪ Short description (title)
    ▪ Long description:
    Describe the why's
    ▪ Reference links
    ▪ Use proper punctuation!
    Voiculescu Bogdan

    View full-size slide

  29. Give Credit Where Credit is Due
    Prefix: description
    Long description explaining why the changes were made,
    why they were made in this way.
    What other solutions were considered and rejected
    and for what reason.
    Reference(s):
    • https://....
    Co-authored-by: Contributor Name

    View full-size slide

  30. Tools of The Trade
    ▪ Amend
    ▪ Interactive Rebase
    ▪ Cherry picking
    Enrica Bressan

    View full-size slide

  31. Cherry Picking
    Commits Files Lines

    View full-size slide

  32. Cherry Picking
    When
    committing
    From other
    commits
    From other
    branches

    View full-size slide

  33. K.C. Hohensee

    View full-size slide

  34. To Force Push Or Not To Force Push
    DO:
    ▪ Non-
    collaborative
    branch,
    not pulled
    ▪ Pulled,
    rebased,
    no changes
    MAYBE
    ▪ Pulled,
    typo/CS fix
    DON'T:
    ▪ Collaborative
    branch,
    not pulled
    ▪ Pulled,
    review has
    started

    View full-size slide

  35. When Things Go
    Wrong

    View full-size slide

  36. Reset vs Revert

    View full-size slide

  37. Reset vs Revert

    View full-size slide

  38. Reset vs Revert

    View full-size slide

  39. Reset vs Revert

    View full-size slide

  40. When Things Go
    Really Wrong

    View full-size slide

  41. Git Bisect
    to the Rescue
    Bad
    Good

    View full-size slide

  42. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?

    View full-size slide

  43. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?

    View full-size slide

  44. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?
    Good or Bad ?

    View full-size slide

  45. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?
    Good or Bad ?

    View full-size slide

  46. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?
    Good or Bad ?
    Good or Bad ?

    View full-size slide

  47. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?
    Good or Bad ?
    Good or Bad ?

    View full-size slide

  48. Git Bisect
    to the Rescue
    Bad
    Good
    Good or Bad ?
    Good or Bad ?
    Good or Bad ?

    View full-size slide

  49. When Things Go
    Really Really REALLY Wrong

    View full-size slide

  50. Keeping Your
    Codebase Clean
    Lisandra Barros Mendonça

    View full-size slide

  51. Commit vs Ignore
    In repo .gitignore .git/info/exclude
    Composer composer.json
    composer.lock
    /vendor/
    composer.lock
    NPM package.json /node_modules/
    package-lock.json
    PHPUnit phpunit.xml.dist phpunit.xml
    .phpunit.result.cache
    custom-phpunit.xml
    IDE of choice /.idea/
    OS specific *.bak
    .Trashes
    [Tt]humbs.db
    *.DS_store

    View full-size slide

  52. Keep Distribution Packages Clean
    # Exclude these files from release archives.
    /.gitattributes export-ignore
    /.gitignore export-ignore
    /phpunit.xml.dist export-ignore
    /tests/ export-ignore
    # Auto detect text files and perform LF normalization
    * text=auto
    # The above will handle all files NOT found below
    *.md text
    .gitattributes

    View full-size slide

  53. Git in Comfort
    Git Kraken SmartGit
    Aurees
    SourceTree
    GitExtensions
    CLI
    GitEye
    Git Cola

    View full-size slide

  54. Thanks!
    Any
    questions ?
    Slides: https://speakerdeck.com/jrf
    Feedback: https://joind.in/talk/dafa1
    @jrf_nl @jrfnl

    View full-size slide