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

Ask Your Code

Ask Your Code

What do we really use version control for at a fundamental level? How do we ask our codebase questions and are the tools we're using able to answer the questions that we really want to ask it? What do you want to ask your code?

Scott Chacon

July 26, 2023
Tweet

More Decks by Scott Chacon

Other Decks in Programming

Transcript

  1. ask your code
    scott chacon
    GitButler

    View Slide

  2. GitButler
    version


    control

    View Slide

  3. GitButler

    View Slide

  4. GitButler

    View Slide

  5. GitButler

    View Slide

  6. GitButler

    View Slide

  7. GitButler
    product


    design
    for version control

    View Slide

  8. first


    principles
    GitButler

    View Slide

  9. WHY?
    GitButler

    View Slide

  10. aunt minnie is


    in the hospital
    GitButler

    View Slide

  11. When you explain a why, you have to
    be in some framework that you


    allow something to be true.
    GitButler

    View Slide

  12. aunt minnie is in the hospital
    GitButler

    View Slide

  13. WHY?
    GitButler

    View Slide

  14. aunt minnie is in the hospital
    GitButler
    she fell and broke her hip

    View Slide

  15. WHY?
    GitButler

    View Slide

  16. aunt minnie is in the hospital
    GitButler
    she fell and broke her hip
    she slipped on some ice

    View Slide

  17. WHY?
    GitButler

    View Slide

  18. aunt minnie is in the hospital
    GitButler
    she fell and broke her hip
    she slipped on some ice
    ice is slippery

    View Slide

  19. WHY?
    GitButler

    View Slide

  20. first


    principles
    GitButler

    View Slide

  21. first


    principles
    GitButler
    for version control

    View Slide

  22. we all use git
    GitButler

    View Slide

  23. WHY?
    GitButler

    View Slide

  24. we all use git
    GitButler
    we need version control

    View Slide

  25. WHY?
    GitButler

    View Slide

  26. we all use git
    GitButler
    we need version control
    to collaborate and save our work

    View Slide

  27. WHY?
    GitButler

    View Slide

  28. we all use git
    GitButler
    we need version control
    to collaborate and save our work
    our computer doesn’t save the
    history of our files or let other people
    access them

    View Slide

  29. WHY?
    GitButler

    View Slide

  30. GitButler
    history saving, file access

    View Slide

  31. GitButler
    history saving, file access
    google docs

    View Slide

  32. GitButler
    what does


    version control
    do?

    View Slide

  33. GitButler
    what does version control do?
    backing up


    commit


    experimenting


    branch, checkout


    collaborating and reviewing


    diff, merge


    moving bits


    push, pull


    archaeology


    log, blame, bisect


    View Slide

  34. GitButler
    what does version control do?
    backing up


    commit


    experimenting


    branch, checkout


    collaborating and reviewing


    diff, merge


    moving bits


    push, pull


    archaeology


    log, blame, bisect


    archaeology


    log, blame, bisect

    View Slide

  35. GitButler
    what does version control do?
    archaeology


    log, blame, bisect

    View Slide

  36. GitButler
    what question


    does this answer?

    View Slide

  37. the


    common


    questions
    GitButler

    View Slide

  38. GitButler
    the common questions
    What are the last few dozen commits


    that have been made to this codebase?

    View Slide

  39. GitButler
    the common questions
    What are the last few dozen commits


    that have been made to this codebase?
    git log

    View Slide

  40. git log —-oneline —-graph

    View Slide

  41. GitButler
    the common questions
    Who is the last person who


    touched this line of code?

    View Slide

  42. git blame -L 15,26 path/to/file

    View Slide

  43. git blame -L 15,26 path/to/file
    git log -L 15,26:path/to/file

    View Slide

  44. git blame -L 15,26 path/to/file
    git log -L 15,26:path/to/file

    View Slide

  45. git blame -L 15,26 path/to/file
    git log -L 15,26:path/to/file

    View Slide

  46. git blame -L 15,26 path/to/file
    git log -L :File:path/to/file

    View Slide

  47. git blame -L 15,26 path/to/file

    View Slide

  48. GitButler
    the common questions
    Who is the last person who


    touched this line of code?
    What are the last few dozen commits


    that have been made to this codebase?

    View Slide

  49. the


    uncommon


    questions
    GitButler

    View Slide

  50. GitButler
    the uncommon questions
    What commits are on this branch


    that are not yet merged


    into this other branch?

    View Slide

  51. View Slide

  52. git log main..self-hosted

    View Slide

  53. git log main..self-hosted

    View Slide

  54. git log main ^self-hosted

    View Slide

  55. git log main ^self-hosted

    View Slide

  56. GitButler
    the uncommon questions
    What commits introduced a change


    that included a speci
    fi
    c string?

    View Slide

  57. git log -S files_watcher -p

    View Slide

  58. GitButler
    the uncommon questions
    What
    fi
    le was this


    function moved from?

    View Slide

  59. git blame -L 15,26 path/to/file

    View Slide

  60. git blame -w -C -C -C —L 15,26 path/to/file

    View Slide

  61. git blame -w -C -C -C —L 15,26 path/to/file

    View Slide

  62. git blame -w -C -C -C —L 15,26 path/to/file

    View Slide

  63. git blame -w -C -C -C —L 15,26 path/to/file

    View Slide

  64. GitButler
    the uncommon questions
    What files are most


    closely related to this file?

    View Slide

  65. What files are most closely related to this file?


    View Slide

  66. What files are most closely related to this file?


    get all the commits that touch this
    fi
    le

    View Slide

  67. What files are most closely related to this file?


    get all the
    fi
    les each commit touches
    get all the commits that touch this
    fi
    le

    View Slide

  68. What files are most closely related to this file?


    print out the top
    fi
    ve
    fi
    les in common

    View Slide

  69. View Slide

  70. the


    impossible


    questions
    GitButler

    View Slide

  71. GitButler
    the impossible questions
    What Pull Requests contributed to this file?


    What code in other repositories are related to this code?


    What were the conversations (in chat or GitHub) my team had around
    this code before it was merged?


    What did the author/s reference when writing this?


    What specifications was this based on?


    What errors were or are commonly created by this code or code
    related to it that I should be aware of before changing?

    View Slide

  72. ask your code?
    GitButler
    what do you want to

    View Slide

  73. thanks!
    @chacon
    GitButler
    speakerdeck.com/schacon
    github.com/schacon
    these slides
    code examples

    View Slide