Git Branch Practice

942 views

Published on

Very simple git branch practice in the real world. Lecture in my company internal training.

Published in: Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
942
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Git Branch Practice

  1. 1. Git Branch Practice Xinguard Training Date:2012.10.28 Speaker: Tiffany Wang
  2. 2. 今天不會講…● 為什麼要用git● git 使用手冊
  3. 3. Agenda簡報檔網址:http://ppt.cc/0tC1 (零踢西一)● Basic Git● Xinguard Git Management● Why Branch● Branch Basic● Git Flow● Something Important About Branch● Git Branch Model, in Reality
  4. 4. 「一流公司想事情透徹(think through),一次就做對事情;而二流公司大家都很忙很忙,但只是救火。」 施崇棠,華碩電腦CEO
  5. 5. Git Basicgit四大基本招● git clone● git commit● git push● git pullgit小白不知道怎麼辦,就一直 "git commit -a"就對了!![note] pull=fetch+merge
  6. 6. Xinguard Git Management (1/2)● Centralize● Two-Level ○ Xinguard local ■ on log server ○ Bitbucket ■ remote backup solution● Principle Please setup your remote origin as Xinguard Localhttps://github.com/git/hello-world.githttps://github.com/git/hello-world.
  7. 7. Xinguard Git Management (2/2) 衛信員工不用管… 請設為origin (default remote) IP.addr=192.168.12.200 push to BitBucketStaging Area push git-xinguard Xinguard as remote backuptest.c, main.c, master git server: BitBucketREADME /src/git/Pra.git $ git add test.c main.c BitBucket: a git service README/home/hsiaoting/Pra.git
  8. 8. Why Branch● 實驗用● 新功能● 修bug● 甚至,開發中都請用非master branch建議:只有在release 時才merge到master(default branch)aka. 永遠都會有正常運作版本給顧客測試實際上:至少要讓master為可正常運作的版本
  9. 9. Branch Basic$ git branch (–list)$ git branch big-icon$ git checkout big-icon(edit…. )$ git commit$ git push origin big-icon #remember to replace yourremote repository name.(When you want to merge big-icon branch with masterbranch… )$ git checkout master$ git merge big-icon
  10. 10. Git Flowa {Model, Tool} based on git branch model● Main Branches -- 骨幹,開發過程永遠存在 ○ Master Branch ○ Develop Branch● Support Branches ○ Feature Branch (前) ○ Release Branch (中) ○ Hotfix Branch (後)
  11. 11. Something Important About Branch本地端與遠端 repository branch 可以不同,再依個別需求做merge (ex: 本地端的master merge到遠端的dev, 這情形很常發生…)$ git checkout --track -b foobar origin/master與別人共用的branch (ex: develop, master) , 或是還沒push回 origin repository 之前,可任意reset 或 rebase, 但是一旦push了,請不要再做特殊更動,容易有錯誤發生
  12. 12. Git Branch Model, in RealityGit Flow Model 真是太難實行了,但…至少:1. 保持master branch (不管Local 或 Remote) 是要可正常編譯、運行的狀態 (production mode)←上面幾頁講過了2. 最好一直保持在develop branch上開發程式, 不管現在的code是好的還是壞的3. 稍具破壞性的實驗也請另開branch ←好像沒有實驗不具破壞 性
  13. 13. Reference● 網管人:Git版本控制系統 輕鬆保留檔案● 寫給大家的Git教學
  14. 14. Lab 實習$ git clone https://github.com/git/hello-world.git(會下載很多種語言的hello-world程式的寫法)建立本地分支、加入檔案、修改、commit、push回Xinguard local (記得在Xinguard local需先建立資料夾)當然,自己寫的小程式也可以直接在BitBucket上頭開專案,然後再push上BitBucket

×