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

Laradebut #03 從 git 入門到團隊合作開發

Laradebut #03 從 git 入門到團隊合作開發

本簡報介紹版本管理 ( Version Control ) git 的基礎指令,一直到基本的團隊合作開發的展示,講解的部份以動畫的方式呈現,希望降低 git 指令入門的門檻。

發表於:Laradebut #3 於 urAd

內容所提到的 github 連結置於:
https://github.com/mouson/laradebut3-demo

錄影紀實:
https://www.youtube.com/watch?v=sEloF3SzGI8

mouson(墨嗓)

August 18, 2016
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

Transcript

  1. ℂ 獈槹
    ک㿁褧ݳ֢樄咳
    Mouson 檔֚ᒓ
    Duncan 讙෈盓
    Laradubet #03 - 2016.08.18 @ i

    View Slide

  2. https://goo.gl/ECb425

    View Slide

  3. 瞲犤च器

    View Slide

  4. git 玟ऒ獤觊
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace

    View Slide

  5. git init - 虻碘䓚ڡত
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git init

    View Slide

  6. git init - 虻碘䓚ڡত
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git init

    View Slide

  7. git status
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git status

    View Slide

  8. git status
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git status

    View Slide

  9. git add [folder/file] 碝ी
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add

    View Slide

  10. git commit
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add git commit

    View Slide

  11. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace

    View Slide

  12. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A

    View Slide

  13. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add
    Hunk A

    View Slide

  14. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add git commit
    Hunk A

    View Slide

  15. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add git commit
    Hunk A
    HASH A

    View Slide

  16. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A
    HASH A

    View Slide

  17. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A
    HASH A
    Hunk B
    Hunk C
    Hunk D

    View Slide

  18. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add
    Hunk A
    HASH A
    Hunk D
    Hunk B
    Hunk C

    View Slide

  19. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add git commit
    Hunk A
    HASH A
    Hunk D
    Hunk B
    Hunk C

    View Slide

  20. 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

    View Slide

  21. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A
    HASH A
    Hunk D
    Hunk B
    Hunk C
    HASH B

    View Slide

  22. git add & commit 奲ݳದ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git add
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B
    Hunk D

    View Slide

  23. 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

    View Slide

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

    View Slide

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

    View Slide

  26. 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^

    View Slide

  27. 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^^

    View Slide

  28. git reset --mixed ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk D
    HASH C
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B

    View Slide

  29. 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

    View Slide

  30. git reset --mixed ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    —mixed HEAD^
    Hunk D
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B

    View Slide

  31. git reset --soft ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk D
    HASH C
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B

    View Slide

  32. 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^

    View Slide

  33. git reset --soft ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B
    —soft HEAD^
    Hunk D

    View Slide

  34. git reset --hard ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk D
    HASH C
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B

    View Slide

  35. 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^

    View Slide

  36. 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^

    View Slide

  37. git reset --hard ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    Hunk A
    HASH A
    Hunk B
    Hunk C
    HASH B
    git reset —hard HEAD^

    View Slide

  38. git reset […] ᯿ᗝ
    Local
    Local Repo/
    Master
    Staging
    Area
    Workspace
    —mixed HEAD^
    git reset —hard HEAD^
    —soft HEAD^

    View Slide

  39. git remote add origin [email protected]
    Local Remote
    Remote Repo/
    Master
    Remote Repo/
    Master
    Local Repo/
    Master
    Staging
    Area
    Workspace
    HASH C
    HASH A
    HASH B

    View Slide

  40. 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

    View Slide

  41. 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

    View Slide

  42. 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

    View Slide

  43. 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

    View Slide

  44. 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

    View Slide

  45. 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

    View Slide

  46. 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

    View Slide

  47. 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

    View Slide

  48. GIT BRANCH

    View Slide

  49. 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

    View Slide

  50. git branch
    Local Remote
    Local Repo/
    Master
    HASH C
    HASH A
    HASH B

    View Slide

  51. git branch
    Local Remote
    Local Repo/
    Master
    HASH C
    HASH A
    HASH B

    View Slide

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

    View Slide

  53. 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

    View Slide

  54. 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

    View Slide

  55. 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

    View Slide

  56. 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

    View Slide

  57. 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)

    View Slide

  58. 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)

    View Slide

  59. Local
    git checkout -b [name]
    A B C
    Master (HEAD)

    View Slide

  60. Local
    git checkout -b [name]
    A B C
    Master
    Develop
    (HEAD)

    View Slide

  61. Local
    git checkout -b [name]
    A B C
    Master
    Develop (HEAD)

    View Slide

  62. Local
    git checkout -b [name]
    A B C
    Master
    Develop (HEAD)

    View Slide

  63. Local
    git checkout -b [name]
    A B C
    Master
    Develop (HEAD)
    D

    View Slide

  64. Local
    git checkout -b [name]
    A B C
    Master
    Develop (HEAD)
    D

    View Slide

  65. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D

    View Slide

  66. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D

    View Slide

  67. Local
    git merge develop --ff (fast-forward)
    A B C
    Develop
    Master (HEAD)
    D E

    View Slide

  68. Local
    git merge develop --ff (fast-forward)
    A B C
    Develop
    Master (HEAD)
    D E

    View Slide

  69. Local
    git merge develop --no-ff
    A B C
    Develop
    Master (HEAD)
    D E

    View Slide

  70. Local
    git merge develop --no-ff
    A B C
    Develop
    Master (HEAD)
    D E
    F

    View Slide

  71. Local
    git merge develop --no-ff
    A B C
    Develop
    Master (HEAD)
    D E
    F

    View Slide

  72. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D E
    F

    View Slide

  73. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D E
    G
    F

    View Slide

  74. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D E
    G
    F

    View Slide

  75. Local
    git merge develop
    A B C
    Develop
    Master (HEAD)
    D E
    G
    F
    ݝ胼蝱ᤈ no-ff

    View Slide

  76. Local
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F

    View Slide

  77. Local
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F
    base

    View Slide

  78. Local
    base
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F

    View Slide

  79. Local
    base
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F
    F'

    View Slide

  80. Local
    base
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F
    F'
    ᯿碝懯ᓒ癩吖

    View Slide

  81. Local
    base
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F
    F'
    ᯿碝懯ᓒ癩吖

    View Slide

  82. Local
    base
    git rebase develop
    A B C
    Develop
    Master (HEAD)
    D E
    F
    F'
    ᯿碝懯ᓒ癩吖

    View Slide

  83. git merge with remote

    View Slide

  84. 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

    View Slide

  85. 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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  90. GIT 䋿率 Demo

    View Slide

  91. ̿碍ڜ懯ᓒ̀䌕礯Օ奧
    • 揲࿄羷碍 (Fibonacci Sequence)
    • P(0)=0, P(1)=1, P(N)=P(N-1)+P(N-2)
    • ૬᮷苭羷碍 (Padovan Sequence)
    • P(0)=P(1)=P(2)= 1, P(N)=P(N-2)+P(N-3)

    View Slide

  92. ̿碍ڜ懯ᓒ̀䌕礯Օ奧

    View Slide

  93. git clone
    Local Remote
    Remote Repo/
    Master
    Remote Repo/
    Master
    Local Repo/
    Master
    Staging
    Area
    Workspace
    git clone

    View Slide

  94. Domo

    View Slide

  95. Demo

    View Slide

  96. View Slide

  97. View Slide

  98. View Slide

  99. 塅ֺጱ Github 蝫奾
    https://github.com/mouson/laradebut3-demo

    View Slide

  100. Recap

    View Slide

  101. View Slide

  102. 蝱褩 git rebase

    View Slide

  103. ԰㵕藲碉
    git rebase -i
    (--interactive)

    View Slide

  104. 狒ኸܻত娄瑽
    git rebase -p
    (--preserve-merges)

    View Slide

  105. Q & A

    View Slide

  106. https://goo.gl/Ifte4S

    View Slide