SlideShare a Scribd company logo
1 of 36
Git
Ted
Agenda
Version Control Intro.
Git Flow
a successful git Model
Git Command Intro ( 主要)
reset/merge/rebase/cherry pick/stash/revert/diff
Version Control
Intro.
b4 version control
沒有 史記歷 錄
不知道版本差別
難以尋找更改的版本
Version Control
Intro.
多人共同開發
程式碼難以合併
Version Control
Intro.
本地
集中式版控
SVN
分散式版控
Git
Version Control
Intro.
server 儲存版本記 ,大家將錄
變更 commit 到 server
if no connection …..
no history
no commit
集中式版控
Version Control
Intro.
大家各自擁有記錄
如果 server 壞掉可使用 local 資料
recovery
可以擁有 local branch
可在 local 端開發完成在 commit 至
server
開 branch 不用錢
no connection….
still has history list
分散式版控
Git Flow
git 開 branch 很方便,但是有沒有流程告訴大家如
何管理 branch?
a successful git branching model
Git Flow
Git Flow
主要分支
master : 永遠處在 production ready
develop : 最新的下次發 開發 態佈 狀
支援分支
feature : 開發新功能,從 develop 分支出來,完成後 merge 回 develop
Release : 準備 release 的版本,只修 bug ,從 develop 分支出來,完成後 merge 回
master and develop
hotFix : 等不及 release 必須馬上修 上線的情況,會從趕 master 分支出來,完成後
merge 回 master 和 develop
Git Command Intro.
Git Command Intro.
Branch Handle
• Merge / Rebase / Cherry Pick
Git Command Intro.
Merge
將兩條分支合併在一起
Rebase
將分支建立在 rebase 的節點上
https://bitbucket.org/Ted_Liang/merge_rebase
Rebase or Merge?
Git Command Intro.
在 branch 上完成了一個功能,該怎麼做?
Merge
Git Command Intro.
git merge master
Merge
Git Command Intro.
回到剛剛的情形
Rebase
Git Command Intro.
Git rebase master
Rebase
WTF?
Git Command Intro.
Rebase
Git Command Intro.
Rebase
When to use Rebase
想測試自己的功能在新版上是否正常 work
尚未 push
Git Command Intro.
Rebase
Never 千萬不要對已經 push 的資料做 rebase
改變 史記 ,會使已歷 錄 pull 該 branch 的人遇到問
題
Git Command Intro.
Merge and Rebase
以下的 branch 爲 myFunction2 做了一次 rebase 之後
想要將 rebase 後的資料 merge 進 master
Git Command Intro.
Merge and Rebase
直接 merge
merge —no-ff (no fast-
ward)
Rebase 的其他用法
rebase -i SHA 重新整理 commit
Git Command Intro.
Rebase
Git Command Intro.
cherry pick
Git Command Intro.
cherry pick
Git Command Intro.
stash
假設我在 branch 做了資料修正,當我準備 push 時,發現線上有兩個
commit
不管他直接 pull
git stash -> pull -> stash apply
Git Command Intro.
Revert
A
B
C
C’
錯誤的 push 時
錯誤的 merge 時
https://bitbucket.org/Ted_Liang/revert_reset
Git Command Intro.
Revert
Delete remote hello
Reset to waaaa
Push again
send mail to everyone
Cant delete main branch
Git Command Intro.
other
Revert 必須注意的事情
使用 revert 之後,假設之後想要把被 Revert 的 資料再度 merge 進去,不能使用 merge( 並
不會發生 merge 的動作 ) ,必須將 Revert 的資料再度 revert
Git Command Intro.
Revert
版本比對
vi ~/.gitconfig
設定 diffmerge
版本比對
git difftool --dir c5ab886
96a9dd5
Q&A
大家盡量問....我盡量答 XD

More Related Content

Similar to Git簡報

Git入门与实践
Git入门与实践Git入门与实践
Git入门与实践LC2009
 
工程師必備第一工具 - Git
工程師必備第一工具 - Git工程師必備第一工具 - Git
工程師必備第一工具 - GitAlan Tsai
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshellNelson Tai
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學littlebtc
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence TutorialHo Kim
 
Git内部培训文档
Git内部培训文档Git内部培训文档
Git内部培训文档superwen
 
GIT實務操作與理論
GIT實務操作與理論GIT實務操作與理論
GIT實務操作與理論鵬 大
 
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹PingLun Liao
 
Git+使用教程
Git+使用教程Git+使用教程
Git+使用教程gemron
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub維佋 唐
 
Introduction to Version Control System for Windows
Introduction to Version Control System for WindowsIntroduction to Version Control System for Windows
Introduction to Version Control System for WindowsPeter Chang
 
Git & git hub v1.2
Git & git hub v1.2Git & git hub v1.2
Git & git hub v1.2Chris Chen
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to gitBo-Yi Wu
 
用Bluemix DevOps 建立良好的團隊開發與版本控制
用Bluemix DevOps 建立良好的團隊開發與版本控制用Bluemix DevOps 建立良好的團隊開發與版本控制
用Bluemix DevOps 建立良好的團隊開發與版本控制Hsuan-Ju Lin
 
James-版本控制
James-版本控制James-版本控制
James-版本控制Study4TW
 

Similar to Git簡報 (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 教學
 
Git share
Git shareGit share
Git share
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence Tutorial
 
Git内部培训文档
Git内部培训文档Git内部培训文档
Git内部培训文档
 
GIT實務操作與理論
GIT實務操作與理論GIT實務操作與理論
GIT實務操作與理論
 
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹
 
Git+使用教程
Git+使用教程Git+使用教程
Git+使用教程
 
Git
GitGit
Git
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
 
Introduction to Version Control System for Windows
Introduction to Version Control System for WindowsIntroduction to Version Control System for Windows
Introduction to Version Control System for Windows
 
Git & git hub v1.2
Git & git hub v1.2Git & git hub v1.2
Git & git hub v1.2
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
用Bluemix DevOps 建立良好的團隊開發與版本控制
用Bluemix DevOps 建立良好的團隊開發與版本控制用Bluemix DevOps 建立良好的團隊開發與版本控制
用Bluemix DevOps 建立良好的團隊開發與版本控制
 
軟體工程(總結篇)
軟體工程(總結篇)軟體工程(總結篇)
軟體工程(總結篇)
 
James-版本控制
James-版本控制James-版本控制
James-版本控制
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
Git 简介
Git 简介Git 简介
Git 简介
 

More from Ted Liang

google play service 7.8 & new tech in M
google play service 7.8 & new tech in M google play service 7.8 & new tech in M
google play service 7.8 & new tech in M Ted Liang
 
what new in google io 2015
what new in google io 2015 what new in google io 2015
what new in google io 2015 Ted Liang
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Ted Liang
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Ted Liang
 
無標題簡報
無標題簡報無標題簡報
無標題簡報Ted Liang
 
Android Gradle about using flavor
Android Gradle about using flavorAndroid Gradle about using flavor
Android Gradle about using flavorTed Liang
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofitTed Liang
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy PatternTed Liang
 
Adapter Pattern
Adapter PatternAdapter Pattern
Adapter PatternTed Liang
 
設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野Ted Liang
 
Design pattern intro
Design pattern introDesign pattern intro
Design pattern introTed Liang
 
物件導向範型
物件導向範型物件導向範型
物件導向範型Ted Liang
 

More from Ted Liang (12)

google play service 7.8 & new tech in M
google play service 7.8 & new tech in M google play service 7.8 & new tech in M
google play service 7.8 & new tech in M
 
what new in google io 2015
what new in google io 2015 what new in google io 2015
what new in google io 2015
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)
 
無標題簡報
無標題簡報無標題簡報
無標題簡報
 
Android Gradle about using flavor
Android Gradle about using flavorAndroid Gradle about using flavor
Android Gradle about using flavor
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofit
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Adapter Pattern
Adapter PatternAdapter Pattern
Adapter Pattern
 
設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野設計模式的解析與活用 -開拓視野
設計模式的解析與活用 -開拓視野
 
Design pattern intro
Design pattern introDesign pattern intro
Design pattern intro
 
物件導向範型
物件導向範型物件導向範型
物件導向範型
 

Git簡報