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

GIT從入門到應用-線上讀書會

 GIT從入門到應用-線上讀書會

在線上讀書會所做的 GIT 分享,此次除了 git 的基礎教學外,也額外在增加關於如何最快找到出錯的 commit 的方法。使用 git bisect 來做二分法除錯。

發表於 2017 年 1 月 10 日 於 線上讀書會

相關錄影:https://www.youtube.com/watch?v=gVByWjwetVc
範例github 連結:https://github.com/mouson/20170110-demo-bisect

PS. 範例僅需要跟著 README 的內容也可以體驗一下 git bisect 的使用情境。

mouson(墨嗓)

January 10, 2017
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

Transcript

  1. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add git commit Hunk A
  2. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add git commit Hunk A HASH A
  3. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace Hunk A HASH A Hunk B Hunk C Hunk D
  4. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add Hunk A HASH A Hunk D Hunk B Hunk C
  5. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add git commit Hunk A HASH A Hunk D Hunk B Hunk C
  6. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add git commit Hunk A HASH A Hunk D Hunk B Hunk C HASH B
  7. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace Hunk A HASH A Hunk D Hunk B Hunk C HASH B
  8. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add Hunk A HASH A Hunk B Hunk C HASH B Hunk D
  9. git add & commit 組合技 Local Local Repo/ Master Staging

    Area Workspace git add git commit Hunk A HASH A Hunk B Hunk C HASH B Hunk D HASH C
  10. Recap • ⼀一個 hash 代表⼀一次 change • ⼀一個 change 可以包含多個

    hunk • ⼀一個 hunk 最⼩小單位是 ⼀一⾏行行
  11. git HEAD Local Local Repo/ Master Staging Area Workspace Hunk

    A HASH A Hunk B Hunk C HASH B Hunk D HASH C
  12. git HEAD Local Local Repo/ Master Staging Area Workspace Hunk

    A HASH A Hunk B Hunk C HASH B Hunk D HASH C HEAD
  13. git HEAD Local Local Repo/ Master Staging Area Workspace Hunk

    A HASH A Hunk B Hunk C HASH B Hunk D HASH C HEAD HEAD^
  14. git HEAD Local Local Repo/ Master Staging Area Workspace Hunk

    A HASH A Hunk B Hunk C HASH B Hunk D HASH C HEAD HEAD^ HEAD^^
  15. git reset --mixed 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B
  16. git reset --mixed 重置 Local Local Repo/ Master Staging Area

    Workspace —mixed HEAD^ Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B
  17. git reset --mixed 重置 Local Local Repo/ Master Staging Area

    Workspace —mixed HEAD^ Hunk D Hunk A HASH A Hunk B Hunk C HASH B
  18. git reset --soft 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B
  19. git reset --soft 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B —soft HEAD^
  20. git reset --soft 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk A HASH A Hunk B Hunk C HASH B —soft HEAD^ Hunk D
  21. git reset --hard 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B
  22. git reset --hard 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D HASH C Hunk A HASH A Hunk B Hunk C HASH B git reset —hard HEAD^
  23. git reset --hard 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk D Hunk A HASH A Hunk B Hunk C HASH B git reset —hard HEAD^
  24. git reset --hard 重置 Local Local Repo/ Master Staging Area

    Workspace Hunk A HASH A Hunk B Hunk C HASH B git reset —hard HEAD^
  25. git reset […] 重置 Local Local Repo/ Master Staging Area

    Workspace —mixed HEAD^ git reset —hard HEAD^ —soft HEAD^
  26. git remote add origin git@git.. Local Remote Local Repo/ Master

    Staging Area Workspace HASH C HASH A HASH B
  27. git remote add origin git@git.. Local Remote Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B
  28. git remote add origin git@git.. Local Remote Remote Repo/ Master

    Remote Repo/ Master Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B
  29. git push -u origin master Local Remote Remote Repo/ Master

    Remote Repo/ Master Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B
  30. git push -u origin master Local Remote Remote Repo/ Master

    Remote Repo/ Master Local Repo/ Master Staging Area Workspace git push HASH C HASH A HASH B HASH C HASH A HASH B
  31. git push -u origin master Local Remote Remote Repo/ Master

    Remote Repo/ Master Local Repo/ Master Staging Area Workspace git push HASH C HASH A HASH B HASH C HASH A HASH B
  32. git push -u origin master Local Remote Remote Repo/ Master

    Remote Repo/ Master Local Repo/ Master Staging Area Workspace git push HASH C HASH A HASH B HASH C HASH A HASH B HASH C HASH A HASH B
  33. git fetch Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B HASH C HASH A HASH B
  34. git fetch Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B HASH D HASH C HASH A HASH B HASH D
  35. git fetch Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B git fetch HASH D HASH C HASH A HASH B HASH D
  36. git fetch Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B git fetch HASH C HASH A HASH B HASH D HASH D
  37. git branch Local Remote Local Repo/ Master Staging Area Workspace

    HASH C HASH A HASH B Remote Repo/ Master Remote Repo/ Master HASH C HASH A HASH B HASH C HASH A HASH B HASH D HASH D
  38. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop
  39. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B
  40. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B
  41. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B
  42. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B A B C
  43. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B A B C Master (HEAD)
  44. git branch Local Remote Local Repo/ Master Local Repo/ Develop

    HASH C HASH A HASH B git branch develop HASH C HASH A HASH B A B C Master Develop (HEAD)
  45. Local git merge develop A B C Develop Master (HEAD)

    D E G F 只能進⾏行行 no-ff
  46. Local git rebase develop A B C Develop Master (HEAD)

    D E F 重新計算差異異 G base
  47. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base
  48. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base
  49. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base
  50. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base G'
  51. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base G'
  52. Local git rebase develop A B C Develop Master (HEAD)

    D E F F' 重新計算差異異 G base G'
  53. git clone Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace git clone
  54. git merge Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B git fetch HASH D HASH C HASH A HASH B HASH D HASH D HASH D
  55. git merge Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace HASH C HASH A HASH B HASH C HASH A HASH B git fetch HASH D HASH C HASH A HASH B HASH D HASH D git merge HASH D HASH D
  56. git pull Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace git fetch git merge
  57. git pull Local Remote Remote Repo/ Master Remote Repo/ Master

    Local Repo/ Master Staging Area Workspace git fetch git merge git pull
  58. git pull --rebase Local Remote Remote Repo/ Master Remote Repo/

    Master Local Repo/ Master Staging Area Workspace git fetch git rebase
  59. git pull --rebase Local Remote Remote Repo/ Master Remote Repo/

    Master Local Repo/ Master Staging Area Workspace git fetch git rebase git pull --rebase
  60. mouson 上傳 Server 由 陳佑⽵竹 取得 Client (mouson) Server Client

    (陳佑⽵竹) 1. git init 2. git add . 3. git commit 4. git remote add origin git@git.. 5. git push -u origin master
  61. mouson 上傳 Server 由 陳佑⽵竹 取得 Client (mouson) Server Client

    (陳佑⽵竹) 1. git init 2. git add . 3. git commit 4. git remote add origin git@git.. 5. git push -u origin master
  62. mouson 上傳 Server 由 陳佑⽵竹 取得 Client (mouson) Server Client

    (陳佑⽵竹) 1. git init 2. git add . 3. git commit 4. git remote add origin git@git.. 5. git push -u origin master 1. git clone git@git....
  63. ⽤用 git blame 找出兇⼿手 v2.3 ? ? ? BAD ?

    ? ? HEAD BAD BAD BAD GOOD GOOD X