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

Git and GitHub Basic with SourceTree

Git and GitHub Basic with SourceTree

這是一份寫給 Git 新手的入門簡報。相信藉由 SourceTree 這套圖形化的版本控制工具,可降低不少入門時的門壏。
 
* Blog - http://note.drx.tw/2015/05/git-and-github-basic-with-sourcetree.html

C754ece92411be3261a2c3f1dd3aa3cc?s=128

Chu-Siang Lai

April 29, 2015
Tweet

Transcript

  1. [ chusiang@nsysucm ~ ] $ cat .profile # Author: 㲺Ռᗼ

    / chusiang.lai (at) gmail.com # Blog: http://note.drx.tw # Modified: 2015-04-29 17:50 GitHub & Bacis with SourceTree 1
  2. 橕ෝ㲺Ռᗼ • 5 ଙ犥Ӥጱ Git ֵአ妿涢牐 • 獮 Foxconn 敟誢ૡ纷䒍牐

    • 匍肬 DrSays IT ૡ纷䒍牐 • ፘ橕֢ߝ޾茐֢物 • LifeZMD • @be_vimmer_tw • ̽ਠ獊አ GNU/Linux ૡ֢̾ • 㲺Ռጱ執懿 2
  3. 伛猋অӞ矐绗ᒌ㻟牫樄ত㾏牦 3

  4. Outline I. Git ฎՋ讕? II. GitHub ݈ฎՋ讕? III. Git &

    GitHub ݢ犥ெ讕ሻ? IV. 10 ೗౮傶 Git य़䒍牐 V. GitHub 褰璤介涢牐 4
  5. Ⅰ. Git ฎՋ讕? 5

  6. –Wikipedia Git ฎӞ㮆獤碂ୗ粚๜矒ګ敟誢牧磧ڡኧ຋羳ේ牨 箓絮艌 (Linus Torvalds) 獺֢牧ෝ 2005 ଙ犥 GPL

    朰ڊ牐磧ڡฎ傶ԧๅ磪硳ሲጱᓕቘ Linux Kernel 樄 咳ᘒ戔懯ጱ牐 6
  7. Git ฎՋ讕? • SCM (Source Code Management, Software Configuration Management)

    • VCS (Version Control Software) • 獤碂ୗጱ粚๜矒ګ羬翄 • ᛔኧ敟誢 (GPL License) 7 ྭ襑 Server牧ݢ櫝娄ֵአ 犋ொᤩ薛䥁牏犋ொ౮傶敟誢疅㱾
  8. ䷱磪粚๜矒ᓕጱӮኴ य़疑᮷妿稲螂ጱ̿ಋ䵝̀ଙդ 8

  9. 9 䲆礯䄸 粚๜矒ګ 翕᪠臻蟠 粚๜矒ګ • FTP 粚๜矒ګ • 瓟婘䲆粚๜矒ګ

    • Google 襇ᒒᏝ繕粚๜矒ګ • Dropbox 粚๜矒ګ • ...
  10. ᮎ֖ሴҨұک皈ฎࣁ䌃Ջ讕ࠡ牦 10

  11. 磪 SVN ጱӮኴ य़疑᮷妿稲螂ጱ̿ಋ䵝̀ଙդ #2 11

  12. ䷱磪翕᪠ฎᥝெ讕䌃 code ࠡ牦牦 12

  13. 磪 Git ጱӮኴ ಋ䵝? 粋 code? 猖猖獤ጱ竃༩ 13

  14. 抑? ࣁ֜碻? ᛔ౯硼蝄 狶ԧՋ讕? ࣁ Git ጱӮኴ愊眅ݢ犥፡ک … 托 奞

    虻 懱 14
  15. 獡蚎螂஠ኸ綫撪 15

  16. –jserv ̿Git ฎӞ㮆ݢ犥虏匍ࣁጱᛔ૩牏螂݄ጱᛔ૩޾๚㬵 ጱᛔ૩وݶ樄咳ጱ粚๜矒ګ羬翄牐̀ 16

  17. Git 10 蝰ଙ牧Linux ԏᆿ 藳犢ฎெ讕ࣁ 10 ॠ獉樄咳ਠ౮ ֋禼ࣁ娄 - http://goo.gl/zvavk3

    17
  18. Ⅱ. GitHub ݈ฎՋ讕? 18

  19. –chusiang GitHub ฎӞ㮆൉׀݋珿ጱ Git դᓕ牏 Issue tracking ... 缛ጱ纷ୗ嘨ᐒԻଘݣ牐 19

  20. GitHub ਥො翕ᒊ https://github.com/ 20

  21. Git Web 21

  22. git diff 22

  23. Issue Tracking 23

  24. Wiki 24

  25. Follwers 25

  26. Ⅲ. Git ޾ GitHub ݢ犥ெ讕ሻ? 26

  27. ग़Ո㶧ݶ樄咳 • LifeZMD 傶 Charlie, Chu, Dick, Olga, Steven, chusiang

    ෝ iDSBG ᒫӣ䌵 HTML5 Hackathon ಅ蕣֢牐 • 穉搴౮婧物ᒫ 4 ݷ牐 • 穉搴碻樌物2 ॠ 1 ज़牐 • 㿁褧Ո碍物6 Ո牐 LifeZMD - http://goo.gl/OHJK9u 27
  28. 覌眲翕ᒊ SM ฎ㮆ֵአ GitHub Pages ๐率޾ ጱ HTML, CSS ޾

    Javascript ಅ䌃౮ ጱय़ਁ䁭 Web Apps牐 SM - http://sm.drx.tw 28
  29. 蝑 Patch 憽஑獨Ոጱ䌕礯犋䄪ਠ聅牫 ᮎ疰ض fork 獨Ոጱ䌕礯牧 硬ਠ code ٚ蝑 Pull

    Requests 㹧牦 @be_vimmer_tw - http://goo.gl/TVYHsL 29
  30. 䌃䨗 • 萞ኧ GitHub ޾ GitBook ๐率ጱ碉 ݳ牧౯㮉ݢ犥ֵአ Markdown 承ဩ

    砰䌃෈ᒍ牧㪔碉ቘ౮㲘牐 • GitBook ݶ碻ඪൔ Web, PDF, ePub ޾ mobi 缛ग़圵໒ୗ牐 ਠ獊አ GNU/Linux ૡ֢ - http://goo.gl/OHJK9u 30
  31. 瞱媲碉ݳ (CI) 砇蟴䔶य़ጱ Jenkins CI牧ܨݢ蝱ᤈ
 ᛔ㵕玕介手 (Web UI, Unit test)牏


    翥捌 (AOSP)牏蝢Ꭳ懱௳ (Email, HipChat, Slack) ... 缛碉ݳ牐 Jenkins CI - https://ci.jenkins-ci.org/ 31
  32. –chusiang ̿磪ԧ Git 疰অ穉䌃纷ୗݢ犥蚤ሻ㻌秚蝿瞁Ӟ䰬牧 ݢ犥褰碻㱪ਂ޾捝玲蝱ଶ牧犋ᓕฎᥝ盠蝧Ꮘ橕螭ฎ ᥝ誢涢ݱ㮆獤ඪ玀眐᮷ݢ犥斕誫ጱ旰ک牐̀ 32

  33. Ⅳ. 10 ೗౮傶 Git य़䒍 33

  34. ࣁ 樄ত ԏ獮殾伛猋 ۑ毆珿ٌԪ牧஠ضڥٌ瑊 ጱ Tool 34

  35. SourceTree Terminal or 35

  36. 螭磪 ᪒᪡࿯竝 ጱ ID ޾ Email 36

  37. # 戔ਧֵአᘏݷ圸 $ git config --global user.name "foo" # 戔ਧ襎ৼמᓟ

    $ git config --global user.email "foo@example.tw" 37
  38. ᒫ 1 ೗物蕦蕣 (clone) 膏ڡত玕 (init) మ盠蝧Ӥಋ牫ᮎ疰ضℂಧ樄ত㹧牦 38

  39. ٚ clone 獮牧 藶ض fork 傶׎ෝݶྍ๜犥ӥ砺֢絑ह牧藶ضᛗ GitHub 蝱ᤈ fork牐 ૢ棎

    39
  40. 蕦蕣 (clone) 舙犋ฎℂᛔ૩ጱ GitHub 蝱ᤈ蕦蕣 (clone)牧毆戔ฎ䷱磪稗褖Ӥ㯽 (push) ጱࡂ牦 40

  41. ૢ棎 ૢ棎 41 # 蕦蕣 (clone) $ git clone git@github.com:chusiang/sandbox.git

    夺ਁ 蟂犩藶硬౮ᛔ૩ጱ癱蒈 夺ਁ蟂犩藶硬౮ᛔ૩ጱ癱蒈 夺ਁ蟂犩藶硬
  42. ڡত玕 (init) ࣁୌ缏Ӟ㮆碝ጱ Git 䌕礯ԏ獮牧౯㮉襑ಋ㵕ୌ缏๜瑿ᒒጱ碍硁䓚 (Local Repository)牧֕舙磪獮 Ո (蝢ଉ䨝ฎ羬翄ᓕቘ㹓) ୌ缏অ牧౲

    fork ٌਙ䌕礯牧蝡碻౯㮉疰ݢ犥ኼ螂牐 42
  43. ૢ棎 ૢ棎 # ୌ缏䌕礯ፓ袅㪔獥矦ᛗ扗ፓ袅皈ӥ $ mkdir /Users/jonny/vcs/demo; cd $_ #

    ୌ缏๜瑿碍硁䓚 (local repository) $ git init 43
  44. ᒫ 2 ೗物碝ी (add)牏ᑏ㵕 (mv)牏㳫ᴻ (rm) ݢమ౮ฎ CRUD 愊ጱ Create,

    Upgrade, Delete牐 44
  45. ݦ棎 # 碝ी (Add)牏㳫ᴻ (Remove) $ git { add |

    rm } README.md # ᑏ㵕 (Move) $ git mv README.md foo.md
  46. ᒫ 3 ೗物൉Ի (commit) ࣁ Git ጱྯӞ㵕愊牧᮷ฎአ commit 㬵懿袅ጱ牐 46

  47. # ൉Ի (Commit) $ git commit README.md git commit ૢ棎

    蜍獈෈ਁ 47
  48. Upgrade to Lv1 48

  49. ᒫ 4 ೗物礚፡制眲 (status) 膏稲ݥ懿袅 (log) ࣁ Git ጱӮኴ蝈᪠碻牧አ status

    ޾ log 疰䌘ԧ牐 49
  50. 礚፡制眲 (status) 匍ࣁ狶کߺӞ㵕ԧ? ፡ status 疰Ꭳ螇ԧ牦 50

  51. # 粚๜制眲 (Status) $ git status git status 51

  52. 礚፡稲ݥ懿袅 (log) ࣁ Console 愊㲺Ռ聜䙼አ git lg ጱ獨ݷ (alias) 㬵፡粚๜䰽牐

    52
  53. # 薪፡粚๜懿袅 $ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)

    %C(bold blue)<%an>%Creset' git log 53
  54. ᒫ 5 ೗物礚፡懿袅 (checkout) 拻ਠԧ㱪ਂ蝱ଶ牧矑ӥ㬵疰ฎ捝玲 (Read) 蝱ଶ牐 54

  55. # 礚፡礓蝱ଶ碻ጱ懿袅 $ git checkout 09a3d66 ૢ棎 ૢ棎 ૢ棎 55

  56. ᒫ 6 ೗物穉䌘粚๜癩吖 (diff) 㴄㴄硬ԧՋ讕 code? 磪 diff ܨݢӞፓ啻簁牐 56

  57. # 穉䌘 (Different) 吚獮粚๜癩吖 $ git diff HEAD 57

  58. Upgrade to Lv2 58

  59. ᒫ 7 ೗物വ蝑 (push) Ӥ㯽ᛗ螐ᒒ (remote) ጱ碍硁䓚 (Repository)牐 59

  60. # വ蝑 (Push) $ git push origin master ૢ棎 ૢ棎

    60
  61. ᒫ 8 ೗物೉玲 (pull) ℂ螐ᒒ (remote) 碍硁䓚 (Repository) ӥ斉牐 61

  62. # ೉玲 (Pull) $ git pull origin master ૢ棎 ૢ棎

    62
  63. ᒫ 9 ೗物䞳祌狕硬 (checkout) 纷ୗ䌃粋ԧ? ᮎ疰᯿毣㬵螂މ牦 63

  64. # 萞ኧ checkout 䞳祌狕硬 $ git checkout README.md ૢ棎 ૢ棎

    64
  65. 65 Upgrade to Lv3

  66. ᒫ܈೗物獤ඪ (branch) 膏ݳ㬫 (merge) 䋊䨝 branch ޾ merge ܨݢ藯ฎ聜஑य़౮ۑێԧ牦 66

  67. 粚๜䰽 ࣁ樄ত獮ض፡Ӟӥ奾ຎ牐 master dev 67

  68. 獤ඪ (branch) ݶӞ稠蝿瞁牧者磪犋ݶጱ獤ඪ玀眐牐 68

  69. # ୌ缏獤ඪ $ git branch dev $ git checkout -b

    dev ૢ棎 master 69 ૢ棎
  70. # ڜڊ獤ඪ $ git branch master 70

  71. # 萞ኧ checkout 獥矦ᛗ dev 獤ඪ $ git checkout dev

    ૢ棎 x2 dev master 71
  72. # ෝ dev 獤ඪ碝ी䲆礯牧㪔൉Ի $ git add branch_demo.txt $ git

    commit -m 'Demo for branch' dev 72
  73. Branch? 膐ಋݢ஑ 樄ԧ碝ጱ branch 盅螭ᥝࣁ碝ጱ branch 愊 commit 螂಍፡஑ک獤ඪ䰽牐 dev

    master Uncommitted changes 73
  74. ݳ㬫 (merge) 玀眐獤ඪԋԧ牧者磪ࢧکԆ娄ጱӞॠ牐 74

  75. ૢ棎 x2 # 萞ኧ checkout 獥矦ᛗ master 獤ඪ $ git

    checkout master dev master 75
  76. # ෝ master ݳ㬫 dev 獤ඪ $ git merge --no-ff

    dev master 76
  77. ݳ㬫ਠ౮牦 master 77

  78. 眅૪聜஑Ӥ犔ஞဩ Congratulation ! 78

  79. Ⅴ. GitHub 褰璤介涢 79

  80. च๜砺֢ (Basic) 1. ጭ獈 Github牐
 - https://github.com/ 2. 䌘 Lab

    ጱ Repository 蝱ᤈ fork牐
 - https://github.com/chusiang/sandbox/ 3. ӥ斉纷ୗ嘨牐
 $ git clone https://github.com/YourName/sandbox.git 4. 碝ी䲆礯㪔൉Ի牐
 $ git { add | status | commit } 5. Ӥ㯽纷ୗ嘨牐
 $ git push 80 Login GitHub fork Repository git clone git add git commit git status git push Finish? Yes No
  81. 蝱褩砺֢ (Advanced) 1. ෝٌਙ᪠䕩ٚ稞ӥ斉纷ୗ嘨牐
 $ git clone https://github.com/YourName/sandbox.git 2. 碝ी牏狕硬牏㳫ᴻ䲆礯㪔൉Իग़稞牐


    $ git { add | mv | rm | status | commit } 3. 碝ी獤ඪ㪔൉Իग़稞牐 4. 獥矦ᛗݱ㮆夵袅讨޾獤ඪ牐
 $ git checkout OXOXOXX 5. ݳ㬫獤ඪ牐 6. Ӥ㯽纷ୗ嘨牐
 $ git push origin master 81 dev master Finish
  82. ૡ珶๐率 82

  83. 2015 2015.10.? - http://mopcon.org 83

  84. ਥො翕ᒊ http://mopcon.org 罭妟ᗭ http://fb.me/mopcon 84

  85. 85

  86. http://coscup.org 86

  87. Q & A 瑥纔ೌ಑訤觬 藶㷢ᘍ匍䁰و執෈կ - http://goo.gl/aqTTYO 87

  88. Reference • 匍䁰و執෈կ - http://goo.gl/aqTTYO • 匍䁰ፗ砮翕࣎ - https://youtu.be/5ftNjrpzVqM •

    蝫糞ৼ᮷胼睞ጱ Git 獈槹瞲ܖ | 揔໒禼 (Backlog) - http://backlogtool.com/git-guide/tw/ • 䌃妔य़疑ጱ Git 硽䋊 | slideshare - http://www.slideshare.net/littlebtc/git-5528339 • Git 䋿率瑽薹 | slideshare - http://www.slideshare.net/pokaichang72/git-42427674 • Git ਥො෈կ - http://git-scm.com/book/zh-tw/v1 • 瑽粙㬵რ物 • 㾴疑瑿ቘ褾扮 - http://www.ngtaiwan.com • 10 Years of Git | Atlassian Git Tutorial - https://www.atlassian.com/git/articles/10-years-of-git/ 88
  89. E N D 89