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 Slide

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

    View Slide

  3. Three Tips

    View Slide

  4. Three Tips
    bisect

    View Slide

  5. Three Tips
    rerere
    bisect

    View Slide

  6. Three Tips
    rerere
    worktree
    bisect

    View Slide

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

    View Slide

  8. v2.3

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  28. 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  44. Three Tips
    rerere
    worktree
    bisect

    View Slide

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

    View Slide