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

20190323_ThreeGitTips-台日技術社群交流會

 20190323_ThreeGitTips-台日技術社群交流會

在台日技術社群交流會所做的分享,這份簡報主要介紹三個 GIT 的指令,分別是 bisect、rerere 以及 worktree:

* bisect 指令,我們可以比較快的找到發生錯誤的 commit
* rerere 指令,可以自動重複上一次的解決衝突的動作
* worktree 在相同的 repo 中,快速建立或取得 branch 在不一樣的工作資料夾中進行檔案修改

bisect 使用的 git repo: https://github.com/mouson/20170110-demo-bisect
rerere, worktree 使用的範例 git repo: https://github.com/mouson/git-rerere-worktree-demo

mouson(墨嗓)

March 23, 2019
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

Transcript

  1. 陳佑⽵竹 Mouson
    2019.03.23 台⽇日技術交流聚會@ 天瓏書局
    Three Tips

    View full-size slide

  2. About Me
    • 陳佑⽵竹,朋友都叫我墨墨嗓
    (Mouson)。專注於資訊科技整
    合、應⽤用、開發⽅方法及研究的T
    型⼈人,現任 PHP 資訊系統分析
    師/⼈人夫/⼀一隻臘腸狗的爸爸/通⽤用
    設計(ユニヴァーサルデザイン)
    推廣。平時喜好⽻羽球、登⼭山及
    ⼿手沖咖啡。
    [email protected]
    • https://fb.me/mouson

    View full-size slide

  3. Three Tips
    bisect

    View full-size slide

  4. Three Tips
    rerere
    bisect

    View full-size slide

  5. Three Tips
    rerere
    worktree
    bisect

    View full-size slide

  6. Use binary search to find the commit
    that introduced a bug
    bisect
    Ref: https://git-scm.com/docs/git-bisect

    View full-size slide

  7. ? ? ? ? ? ? ? HEAD
    Some feature was a failure after merge
    v2.3

    View full-size slide

  8. ? ? ? ? ? ? ? HEAD
    Some feature was a failure after merge
    v2.3
    git bisect start HEAD v2.3

    View full-size slide

  9. Use git bisect search failure commit
    v2.3 ? ? ? ? ? ? ? HEAD
    git bisect start HEAD v2.3

    View full-size slide

  10. Use git bisect search failure commit
    v2.3 ? ? ? ? ? ? ? HEAD
    git bisect start HEAD v2.3

    View full-size slide

  11. Use git bisect search failure commit
    v2.3 ? ? ? ? ? ? ? HEAD
    BAD
    git bisect start HEAD v2.3

    View full-size slide

  12. Use git bisect search failure commit
    v2.3 ? ? ? ? ? ? ? HEAD
    BAD

    View full-size slide

  13. Use git bisect search failure commit
    v2.3 ? ? ? ? ? ? ? HEAD
    BAD
    git bisect bad

    View full-size slide

  14. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    git bisect bad

    View full-size slide

  15. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    git bisect bad

    View full-size slide

  16. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD

    View full-size slide

  17. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD

    View full-size slide

  18. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD

    View full-size slide

  19. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    git bisect good

    View full-size slide

  20. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    git bisect good

    View full-size slide

  21. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    GOOD
    git bisect good

    View full-size slide

  22. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    GOOD

    View full-size slide

  23. Use git bisect search failure commit
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    GOOD X

    View full-size slide

  24. use git blame find detail
    v2.3 ? ? ? BAD ? ? ? HEAD
    BAD BAD
    BAD
    GOOD
    GOOD X

    View full-size slide

  25. Demo
    https://goo.gl/xGJxta
    UnitTest can be successfully
    executed in v2.0, but failed in the
    current version.

    View full-size slide

  26. Demo
    Manuel:
    1. git bisect start HEAD v2.0
    2. phpunit / git bisect bad
    3. phpunit / git bisect good
    4. phpunit / git bisect good
    5. git bisect reset
    https://goo.gl/xGJxta

    View full-size slide

  27. Demo
    Auto:
    1. git bisect start HEAD v2.0
    2. git bisect run ./vendor/bin/phpunit
    https://goo.gl/xGJxta

    View full-size slide

  28. Reuse recorded resolution of conflicted
    merges
    rerere
    https://git-scm.com/docs/git-rerere

    View full-size slide

  29. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  30. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!
    I have a Apple Pen !!!

    View full-size slide

  31. GIT Rerere Demo
    1. enable rerere feature
    git config --global rerere.enabled true
    https://goo.gl/8wj1he

    View full-size slide

  32. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  33. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  34. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  35. Local
    GIT Rerere Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  36. Manage multiple working trees
    worktree
    https://git-scm.com/docs/git-worktree

    View full-size slide

  37. Local
    GIT worktree Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  38. Local
    GIT worktree Sample
    I have a World!!!
    feature
    master
    I have a Apple !!!
    I have a Pen !!!

    View full-size slide

  39. Local
    GIT worktree Sample
    I have a World!!!
    I have a Apple !!!
    master
    I have a Pen !!!
    feature
    1. Rebase

    View full-size slide

  40. Local
    GIT worktree Sample
    I have a World!!!
    I have a Apple !!!
    master
    feature
    I have a Apple Pen !!!
    1. Rebase

    View full-size slide

  41. Local
    GIT worktree Sample
    I have a World!!!
    I have a Apple !!!
    feature
    I have a Apple Pen !!!
    1. Rebase
    2. Merge
    master

    View full-size slide

  42. Three Tips
    rerere
    worktree
    bisect

    View full-size slide

  43. Q & A
    陳佑⽵竹 Mouson
    https://facebook.com/mouson

    View full-size slide