SlideShare a Scribd company logo
1 of 14
Download to read offline
Git Branch Practice


                Xinguard Training
                 Date:2012.10.28
            Speaker: Tiffany Wang
今天不會講…


● 為什麼要用git
● git 使用手冊
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
「一流公司想事情透徹(think through),一
次就做對事情;而二流公司大家都很忙很
忙,但只是救火。」
            施崇棠,華碩電腦CEO
Git Basic
git四大基本招
● git clone
● git commit
● git push
● git pull

git小白不知道怎麼辦,就一直 "git commit -a"就對了!!




[note] pull=fetch+merge
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 Local
https://github.com/git/hello-world.
githttps://github.com/git/hello-world.
Xinguard Git Management (2/2)

                                                                      衛信員工不用管…


                                       請設為origin (default remote)
                                       IP.addr=192.168.12.200
                                                                     push to BitBucket
Staging Area            push git-xinguard            Xinguard        as remote backup
test.c, main.c,         master                      git server:                                BitBucket
README                                            /src/git/Pra.git

            $ git add test.c main.c                                                  BitBucket: a git service
            README

/home/hsiaoting/
Pra.git
Why Branch
●   實驗用
●   新功能
●   修bug
●   甚至,開發中都請用非master branch

建議:只有在release 時才merge到master
(default branch)
aka. 永遠都會有正常運作版本給顧客測試
實際上:至少要讓master為可正常運作的版本
Branch Basic
$ git branch (–list)
$ git branch big-icon
$ git checkout big-icon
(edit…. )
$ git commit
$ git push origin big-icon #remember to replace your
remote repository name.
(When you want to merge big-icon branch with master
branch… )
$ git checkout master
$ git merge big-icon
Git Flow

a {Model, Tool} based on git branch model

● Main Branches -- 骨幹,開發過程永遠存在
  ○ Master Branch
  ○ Develop Branch
● Support Branches
  ○ Feature Branch (前)
  ○ Release Branch (中)
  ○ Hotfix Branch (後)
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了,請不要再做
特殊更動,容易有錯誤發生
Git Branch Model, in Reality
Git Flow Model 真是太難實行了,但…

至少:
1. 保持master branch (不管Local 或 Remote)
   是要可正常編譯、運行的狀態 (production
   mode)←上面幾頁講過了

2. 最好一直保持在develop branch上開發程式,
   不管現在的code是好的還是壞的
3. 稍具破壞性的實驗也請另開branch          ←好像沒有實驗不具破壞
  性
Reference
● 網管人:Git版本控制系統 輕鬆保留檔案

● 寫給大家的Git教學
Lab 實習

$ git clone  https://github.com/git/hello-world.git
(會下載很多種語言的hello-world程式的寫法)

建立本地分支、加入檔案、修改、commit、push回
Xinguard local (記得在Xinguard local需先建立
資料夾)

當然,自己寫的小程式也可以直接在BitBucket上
頭開專案,然後再push上BitBucket

More Related Content

Similar to Git Branch Practice

Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹Max Ma
 
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹PingLun Liao
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshellNelson Tai
 
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战icy leaf
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to gitBo-Yi Wu
 
GIT實務操作與理論
GIT實務操作與理論GIT實務操作與理論
GIT實務操作與理論鵬 大
 
Git and git hub
Git and git hubGit and git hub
Git and git hub唯 李
 
Git 超簡單學習懶人包(軟體程式版本控管系統)
Git 超簡單學習懶人包(軟體程式版本控管系統)Git 超簡單學習懶人包(軟體程式版本控管系統)
Git 超簡單學習懶人包(軟體程式版本控管系統)flylon
 
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作奕浦 郭
 
Git 使用介绍
Git 使用介绍Git 使用介绍
Git 使用介绍medcl
 
Git原理与实战 201607
Git原理与实战 201607Git原理与实战 201607
Git原理与实战 201607Charles Tang
 
Git tutorial for windows user (給 Windows user 的 Git 教學)
Git tutorial for windows user (給 Windows user 的 Git 教學)Git tutorial for windows user (給 Windows user 的 Git 教學)
Git tutorial for windows user (給 Windows user 的 Git 教學)Cloud Tu
 
大家應該都要會的工具 Git 從放棄到會用2-分支篇
大家應該都要會的工具 Git   從放棄到會用2-分支篇大家應該都要會的工具 Git   從放棄到會用2-分支篇
大家應該都要會的工具 Git 從放棄到會用2-分支篇Alan Tsai
 
Git flow
Git flowGit flow
Git flowshaokun
 
Git使用入门
Git使用入门Git使用入门
Git使用入门dpf2e
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence TutorialHo Kim
 

Similar to Git Branch Practice (20)

Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹
 
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
GIT實務操作與理論
GIT實務操作與理論GIT實務操作與理論
GIT實務操作與理論
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 
Git 超簡單學習懶人包(軟體程式版本控管系統)
Git 超簡單學習懶人包(軟體程式版本控管系統)Git 超簡單學習懶人包(軟體程式版本控管系統)
Git 超簡單學習懶人包(軟體程式版本控管系統)
 
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作
 
Git 使用介绍
Git 使用介绍Git 使用介绍
Git 使用介绍
 
Git原理与实战 201607
Git原理与实战 201607Git原理与实战 201607
Git原理与实战 201607
 
Git tutorial for windows user (給 Windows user 的 Git 教學)
Git tutorial for windows user (給 Windows user 的 Git 教學)Git tutorial for windows user (給 Windows user 的 Git 教學)
Git tutorial for windows user (給 Windows user 的 Git 教學)
 
Git入門介紹
Git入門介紹Git入門介紹
Git入門介紹
 
大家應該都要會的工具 Git 從放棄到會用2-分支篇
大家應該都要會的工具 Git   從放棄到會用2-分支篇大家應該都要會的工具 Git   從放棄到會用2-分支篇
大家應該都要會的工具 Git 從放棄到會用2-分支篇
 
Git 教學
Git 教學Git 教學
Git 教學
 
Git flow
Git flowGit flow
Git flow
 
Git share
Git shareGit share
Git share
 
Git 版本控制 (使用教學)
Git 版本控制 (使用教學)Git 版本控制 (使用教學)
Git 版本控制 (使用教學)
 
Git使用入门
Git使用入门Git使用入门
Git使用入门
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence Tutorial
 

Git Branch Practice

  • 1. Git Branch Practice Xinguard Training Date:2012.10.28 Speaker: Tiffany Wang
  • 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
  • 5. Git Basic git四大基本招 ● git clone ● git commit ● git push ● git pull git小白不知道怎麼辦,就一直 "git commit -a"就對了!! [note] pull=fetch+merge
  • 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 Local https://github.com/git/hello-world. githttps://github.com/git/hello-world.
  • 7. Xinguard Git Management (2/2) 衛信員工不用管… 請設為origin (default remote) IP.addr=192.168.12.200 push to BitBucket Staging Area push git-xinguard Xinguard as remote backup test.c, main.c, master git server: BitBucket README /src/git/Pra.git $ git add test.c main.c BitBucket: a git service README /home/hsiaoting/ Pra.git
  • 8. Why Branch ● 實驗用 ● 新功能 ● 修bug ● 甚至,開發中都請用非master branch 建議:只有在release 時才merge到master (default branch) aka. 永遠都會有正常運作版本給顧客測試 實際上:至少要讓master為可正常運作的版本
  • 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 your remote repository name. (When you want to merge big-icon branch with master branch… ) $ git checkout master $ git merge big-icon
  • 10. Git Flow a {Model, Tool} based on git branch model ● Main Branches -- 骨幹,開發過程永遠存在 ○ Master Branch ○ Develop Branch ● Support Branches ○ Feature Branch (前) ○ Release Branch (中) ○ Hotfix Branch (後)
  • 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. Git Branch Model, in Reality Git Flow Model 真是太難實行了,但… 至少: 1. 保持master branch (不管Local 或 Remote) 是要可正常編譯、運行的狀態 (production mode)←上面幾頁講過了 2. 最好一直保持在develop branch上開發程式, 不管現在的code是好的還是壞的 3. 稍具破壞性的實驗也請另開branch ←好像沒有實驗不具破壞 性
  • 14. Lab 實習 $ git clone https://github.com/git/hello-world.git (會下載很多種語言的hello-world程式的寫法) 建立本地分支、加入檔案、修改、commit、push回 Xinguard local (記得在Xinguard local需先建立 資料夾) 當然,自己寫的小程式也可以直接在BitBucket上 頭開專案,然後再push上BitBucket