Git Workshop 02

Git Workshop 02

481a04548eda340e5cf166b487792ee5?s=128

Li-Hsuan Chen

September 29, 2016
Tweet

Transcript

  1. (JU8PSLTIPQ 痧✳㔐  ꤫愴蠩

  2. 㥶卓⡹殹♴聃♶䥢 〳⟃꼛♳䩧倬䧮

  3. 㣐笧 ˖ 㔐瘸⵹♧妄㉏⽷涸㉏겗 ˖ ⴕ佅㻜⡲ ˖ 倞㟞莅ざ⢘ⴕ佅 ˖ 贖椚遼瑳 ˖

    ⴕ佅涸溫꬗湡
  4. 㔐瘸㉏겗

  5. 䙦랃嫲鯱晝劥꟦涸䊴殯

  6. 䙦랃嫲鯱晝劥꟦涸䊴殯 ˖ (JU剤鸏⦐䭸⟂〳⟃麨䧭 ˖ ♶麕Ꟛ涮䊨Ⱘ鸒䌢鿪〳⟃䍲⡹刿㺂僒麨䧭 ˖ 4PVSDF5SFF ˖ 9DPEF ˖

    ˘瘞瘞 $ git diff [commit-1-id] [commit-2-id]
  7. 笞麌莅Ꟛ涮ず儘鹎遤儘 㥶⡦鋊ⷔⴕ佅

  8. 笞麌莅Ꟛ涮ず儘鹎遤儘 㥶⡦鋊ⷔⴕ佅 ˖ HJUPX剤㛇燊涸崩玑〳⟃黾䗅 ˖ ꆚ㼩笞麌㢵Ꟛ♧佅笞麌欽涸⚺ⴕ佅 ˖ ♶銴雊笞麌ㄤꟚ涮欽ⴕ佅涸Ⰹ㺂湱䊴㣖㢵 git-flow

  9. ざ⢘焥ⵌ遼瑳 鑪㥶⡦贖椚

  10. Ꟛ㼠갤佞崞⹛涸须俲

  11. 醳绢♧♴

  12. (JU涸♲⦐ꥣ媯 8PSLJOH%JSFDUPSZ 䊨⡲湡ꏗ 4UBHF *OEFY  程䒸⼦ -PDBM3FQPTJUPSZ 劥㖒⮭㶸䏨 劢鄄鷆髠涸墂呪

    佞㖈TUBHF涸墂呪隶刿 䩞〳⟃鄄⸈Ⰵ晝劥䱾ⵖ 鄄晝劥䱾ⵖ涸墂呪
  13. (JU涸♲⦐ꥣ媯 8PSLJOH%JSFDUPSZ 䊨⡲湡ꏗ 4UBHF *OEFY  程䒸⼦ -PDBM3FQPTJUPSZ 劥㖒⮭㶸䏨 劢鄄鷆髠涸墂呪

    佞㖈TUBHF涸墂呪隶刿 䩞〳⟃鄄⸈Ⰵ晝劥䱾ⵖ 鄄晝劥䱾ⵖ涸墂呪 $ git init
  14. (JU涸♲⦐ꥣ媯 8PSLJOH%JSFDUPSZ 䊨⡲湡ꏗ 4UBHF *OEFY  程䒸⼦ -PDBM3FQPTJUPSZ 劥㖒⮭㶸䏨 劢鄄鷆髠涸墂呪

    佞㖈TUBHF涸墂呪隶刿 䩞〳⟃鄄⸈Ⰵ晝劥䱾ⵖ 鄄晝劥䱾ⵖ涸墂呪 $ touch a.txt
  15. (JU涸♲⦐ꥣ媯 8PSLJOH%JSFDUPSZ 䊨⡲湡ꏗ 4UBHF *OEFY  程䒸⼦ -PDBM3FQPTJUPSZ 劥㖒⮭㶸䏨 劢鄄鷆髠涸墂呪

    佞㖈TUBHF涸墂呪隶刿 䩞〳⟃鄄⸈Ⰵ晝劥䱾ⵖ 鄄晝劥䱾ⵖ涸墂呪 $ git add a.txt
  16. (JU涸♲⦐ꥣ媯 8PSLJOH%JSFDUPSZ 䊨⡲湡ꏗ 4UBHF *OEFY  程䒸⼦ -PDBM3FQPTJUPSZ 劥㖒⮭㶸䏨 劢鄄鷆髠涸墂呪

    佞㖈TUBHF涸墂呪隶刿 䩞〳⟃鄄⸈Ⰵ晝劥䱾ⵖ 鄄晝劥䱾ⵖ涸墂呪 $ git commit -m “add a.txt”
  17. 鹎Ⰵ姻겗

  18. #SBODI

  19. 捀➊랃銴欽#SBODI ˖ ꥬꨆ䊨⡲橇㞯㥶 ˖ 㢵➃⼿⡲ ˖ ♶ずꥣ媯涮⡑TUBHJOH QSPEVDUJPO ˖ ⸆腋鑑⨞

  20. 倞㟞CSBODI⚛DPNNJU $ cd /to/your/path $ git init $ touch a.txt

    $ git add a.txt $ git commit -m “add a.txt” $ git branch my-branch $ git checkout my-branch $ touch b.txt $ git add b.txt $ git commit -m “add b.txt” ⯓⹛䩛⨞⨞溏 㖈麕玑⚥欽4PVSDF5SFF溏溏䧭卓
  21. 倞㟞CSBODI ˖ branch倞㟞ⴕ佅涸䭸⟂ ˖ my-branchⴕ佅涸そ珖〳⟃荈㹁纏 $ git branch my-branch

  22. ⴗ䳖䊨⡲ⴕ佅 ˖ checkoutⴗ䳖䊨⡲䨾㖈⡙縨涸䭸⟂ ˖ my-branch銴⵹䖃涸⡙縨㖈鸏酭僽➿邍銴⵹ 䖃涸CSBODI $ git checkout my-branch

    鑑衽䪪䪪溏HJU鼩〳⟃DIFDLPVU➊랃匌銯
  23. ざ⢘㻨岁 $ git branch my-branch $ git checkout my-branch 㥶卓⡹濼麥鸏⦐CSBODI僽倞涸

    〳⟃鸏垺㻨 $ git checkout -b my-branch
  24. 倞㟞CSBODI⚛DPNNJU $ cd /to/your/path $ git init $ touch a.txt

    $ git add a.txt $ git commit -m “add a.txt” $ git checkout -b my-branch $ touch b.txt $ git add b.txt $ git commit -m “add b.txt”
  25. ざ⢘CSBODI … (前略略) $ git checkout master $ git merge

    my-branch ⯓⹛䩛⨞⨞溏 㖈麕玑⚥欽4PVSDF5SFF溏溏䧭卓
  26. 剤尝剤涮欰✫➊랃✲

  27. CSBODI♶鋅✫

  28. ⴗ䳖䊨⡲ⴕ佅 ˖ checkoutⴗ䳖䊨⡲䨾㖈⡙縨涸䭸⟂ ˖ master銴⵹䖃涸⡙縨㖈鸏酭僽➿邍銴⵹䖃涸 CSBODI⛳㽠僽갸鏤涸⚺銴ⴕ佅 $ git checkout master

  29. 䘰鱲 ˖ (JU㖈ざ⢘ⴕ佅儘剚㖈䗳銴䞕䕎♴鍸涮䘰鱲堥 ⵖ fast forward Updating 464aead..0169033 Fast-forward 鸏Ⰽ⦐*%㣐㹻剚♶♧垺

  30. 䘰鱲 ˖ (JU㖈ざ⢘ⴕ佅儘剚㖈䗳銴䞕䕎♴鍸涮䘰鱲堥 ⵖ ˖ 殹㥠錏䖤〫銴獵⹛CSBODI涸剓⵹畮⽰〳㽠剚湬 䱺獵⹛♶剚倞㟞♧⦐NFSHF涸DPNNJU ˖ 〫銴鄄ざ⢘鹎涸CSBODI㖈ⴕ佅ⴀ植䖕剤倞涸 DPNNJU㽠♶剚鄄䘰鱲

    fast forward
  31. 鼚⯝䘰鱲 $ git merge --no-ff my-branch

  32. 鑬稣➝稲俒畎〳鋅IUUQCJUMZHXOP

  33. 鑬稣➝稲俒畎〳鋅IUUQCJUMZHXOP

  34. 鑬稣➝稲俒畎〳鋅IUUQCJUMZHXOP

  35. 鑬稣➝稲俒畎〳鋅IUUQCJUMZHXOP

  36. 遼瑳 $POJDU

  37. 殹剤Ⰽ⦐ⴕ佅 ず儘⥜佖♧⦐墂呪

  38. 㽠剤〳腋涮欰遼瑳 殹NFSHF涸麕玑⚥剤遼瑳涮欰儘㽠剚⚥倬NFSHF

  39. 遼瑳涸垦爚 ˖ 錚㻌墂呪剤ㆭ❉隶⻋ ˖ 对㹁銴殆ㆭ⦐鿈ⴕ⚛䗳갭銴䪾鸏❉垦爚獵ꤑ ˖ ꬒ竤뀿 <<<<< ===== >>>>>

  40. 遼瑳鍑对㸤䧭䖕 ˖ 鍑对㸤䧭儘䗳갭DPNNJU • git add . // ઌ೺໨㑚Ճೖ stage

    • git commit // ࣥߦ commit ˖ 岤䠑搂岁鍑对儘䗳갭銴鷎ⴀNFSHF垸䒭 • git merge --abort ˖ 岤䠑剤㼠呪墂䚍颶涸㼠呪䗳갭銴增叆僽や〳管陼麕ㄤ齅鱀姻焷䩞 腋鹎遤NFSHFDPNNJU <<<<< ===== >>>>>
  41. ⴕ佅涸溫꬗湡

  42. ⴕ佅♶僽♧哭箁 劥颶⢵铞

  43. ⴕ佅僽➊랃 ˖ HEAD湡⵹䨾㖈涸⡙縨 ˖ ➮㶸衽䭸ぢ涸⡙縨〳⟃僽DPNNJU〳⟃僽♧⦐ CSBODI涸墂呪⡙縨 ˖ #SBODI〫僽♧⦐㶸剤DPNNJUJE涸墂呪 ˖ ⴕ佅僽겳⡂䭸垦涸嚌䙂

    ˖ 鮿넓剤鳵岁殥箁ⴀ⢵僽㔔捀➮⦛䭸ⵌ涸DPNNJU剤 QBSFOUDPNNJU
  44. cf1dcd… master cf1dcd… NBTUFS )&"% ref: refs/heads/master HEAD

  45. 〳⟃⨞➊랃✲ 㼭䗱捀♳

  46. 湡⵹捀姺涸䭸⟂ • git init • git add <filename> • git

    commit -m “message” • git branch <branch name> • git checkout <branch name> • git checkout -b <branch name> • git merge <branch name> • git merge --no-ff <branch name> • git merge --abort • git diff <commit id 1> <commit id 2>
  47. 籏穡 ˖ 捀➊랃銴欽ⴕ佅 ˖ 㥶⡦䒊用ⴕ佅ㄤざ⢘ⴕ佅 ˖ ➊랃僽捀➊랃剚剤'BTU'PXBSE䘰鱲⟃⿻ 㥶⡦鼚⯝ ˖ 㥶⡦㖈ざ⢘ⴕ佅儘鍑对遼瑳ㄤ岤䠑✲갪

    ˖ ⴕ佅涸劥颶僽➊랃
  48. 2"儘꟦

  49. 5IBOL:PV