SlideShare a Scribd company logo
1 of 55
VSTS – GIT
WITH VISUAL STUDIO
WORKSHOP
陳傳興, BRUCE CHEN
HTTPS://KKBRUCE.TW
HTTP://BLOG.KKBRUCE.NET
VISUAL STUDIO TEAM SERVICES
• https://www.visualstudio.com/products/visual-studio-team-services-vs
• 個人均可免費申請使用。
• 5 人以下團隊免費使用。
GIT AND GITHUB
• Git 是分散式 Version Control 軟體
• Github 以 git 為基礎擴充的伺服器服務,
使專案更便於協作與發佈
• VSTS 支援 Git 版控
GIT 2.7.4
• Git for Windows 2.7.4 之前含一個重大漏洞
( http://mvc.tw/004N ),請更新至最新版。
• Download: https://git-scm.com/
VSTS – GIT
TEAM EXPLORER – SELECT GIT PROJECT
TEAM EXPORER - CLONE
NEW PROEJCT
CHANGES
• 第一次,請先確認 Configure 裡的個人資料
CONFIGURE
• Developer 個人資料
GITHUB FLOW
• 適合中、小型團隊使用。
• https://guides.github.com/introduction/flow/
STEP 1. CREATE A BRANCH
• master 代表隨時可上戰場的版本
• master 僅進行分支與合併
• 開發應該在其他 Branch 上進行
• 取個好名子
• fix-bugid-9527
• cool-feature-async
• users/kkbruce/test-img-resize (建議用”/”)
• 分支命名規範:http://mvc.tw/004M
STEP 2. COMMIT CHANGES
• Commit 到你的 branch。
• 每次的 commit 都代表往前一小步(一個節點)。
• 為了 bug 或 feature,通常會進行多個 commit。
STEP 2.1 IGNORE
• Settings  Git  Repository Settings
• /.gitIgnore:排除的檔案
• /.gitattributes:針對特定路徑的設定值被稱為
Git 屬性(attributes)
• https://www.gitignore.io/
唯一的指令
• 已提交至 Repository 的檔案,事後再設
定 .gitignore 是沒有用的。
• 可透過指令明確跟 Git 說此檔案不需要版本控
管了。
• git rm --cached 檔案名稱
STEP 3. PUSH YOUR BRANCH
• Push 你的 branch 到遠端儲存庫。
STEP 4. CREATE A PULL REQUEST
• 通知某(些)人進行 Code Review,以提供更多 feedback。
• 換個說法,分支進行合併前進行最後的討論。
• 也許會進行更多的 commit 與 push。
• 由分支負責人進行同意合併動作。
STEP 5. COMPLETE PULL REQUEST
• 解決任何的衝突,以完成分支合併。
CHANGES(變更)
• 確認 commit 的 Branch 是否正確
關聯 WORKITEM (重要)
VSTS定義查詢
• Query在VSTS去定義
• My Queries 僅自己使用的查詢
• Sheard Queries 是共享的查詢
QUERIES SAMPLE
Assigned to All Task
ACTIONS(動作)
SYNC(同步)
• Commit 是簽入至本機儲存庫。
• Sync 才會同步至遠端儲存庫。
• 可 Commit 多個本機的版本後再執行 Sync。
HOME – SYNC(同步)
VSTS – CODE / EXPLORER
COMMIT 連續技
• Commit
• Commt and Push
• Commit and Sync
SYNC – PUSH AND PULL
push
• 將本機變更推送到遠端
pull
• 將遠端變更提取到本機
BRANCHES
NEW BRANCH
PUBLISH BRANCH
LOCAL BRANCH
• 建立後第一次需要 Publish Branch 至 Server
• 後續就是不斷 commit 與 push。
PULL REQUESTS
• Pull Request 字面為「提取要求」,代表子分
支請求父分支擁有者給提取回去的要求。
• Pull Requests 是一個通用的工作流程,即是對
branch 進行 Code Review 與合併。
• 換句話說,目前 branch 已開發、測試至可整
合的程度,希望專案擁有者進行審查與合併
的動作。
NEW PULL REQUEST
• Pull 已完成的 commit 至遠端。
• 建立 Pull Requests
• 審查與完成審查需連線到 VSTS (online) 完成。
TITLE & DESCRIPTION
• Title 簡明說明此次 pull request 的更改
• Description 簡明說明此更改如何實作以及其
他有助理解此更改的資源。
• 還可指定 Reviewers 與 Work Items
DISCUSSION
FILES
COMMITS
COMPLETE PULL REQUEST
• 遠端同意後,記的本機切換回 master 分支(本
範例) Sync 一下。
MASTER - HISTORY
PULLING
Fetch 下載所做的更改,但不套用在你的程式碼
Merge 套用取自 Fetch 到你本地儲存庫的分支
Pull 這是一次執行 Fetch 與 Merge 的簡單作法。
MERGE
• Team Explorer 會在你執行 pull 或 sync 動作時
會進行 merge。
• Sync 是 pull 與 push 的組合操作,它是同步本
地與遠端的分支的 commit 資料。
MERGE CONFLICTS
• 同一支檔案被多人異動。
• Git 無法解決,則產生合併衝突。
MERGE CONFLICTS
• 以本機儲存庫為主
• 以遠端儲存庫為主
GIT BRANCHING MODEL
• 2010年時,有位 Vincent Driessen 整理出了一套
Git branching model
主要(MASTER)分支
• master:處於production-ready的狀態,只從 release 與
hotfix merge 回來,不直接在上面 commit 變更。換句
話說,即是該版的source code是可運行的、符合專案
需求的、設計良好的、穩定的、可維護的、可擴展的
及已文件化的。
• develop:也稱開發分支為整合分支,自動化測試所根
據的程式碼(source code)即是以此分支上的版本為基準
來進行測試。
支援分支
• Feature branches:從 develop 分支出來,當功能開發修
改完成後 merge 回 develop
• Release branches:從 develop 分支出來,是準備釋出的
版本,只修改版本號與 bug,完成後 merge 回 develop
與 master,並在 master 標上版本號的 tag
• Hotfix branches:從 master 分支出來,主要是處理已釋
出版本需要立即修改的錯誤,完成後 merge 回 develop
與 master,並在 master 標上版本號的 tag
• 支援分支與主要分支最大的差別在於,支援分支在支援
任務結束後就會移除,而主要分支則是始終存在。
功能(FEATURE)分支
• 從develop branch分離。
• 合併回develop branch。
• 分支命名規則:除了master, develop, release-, or hotfix-
以外的功能名稱都行。
• 此分支通常只會存在於該功能的開發者的本機端的儲存
庫(local repository),遠端的中央儲存庫(remote
repository 或者 remote origin)是不會有的。
發佈(RELEASE)分支
• 從開發分支分離。
• 合併回開發分支或主要分支。
• 分支命名規則:release-*
發佈分支
• Release branch分支是為了新版本發佈而存在
• 合適進行整合性測試,並進行小bug修復及增加一些metadata(例如版本號或是build日期等)。
• 制定版本號碼的最佳時機是在開發佈分支時。
修補(HOTFIX)分支
• 通常是因為出現了一個急需在短時間內修復的bug(急
件) ,無法等到下一次發佈時才修復。
• 此分支通常從主分支某個已標上tag的commit分出,bug
經過修復後,可合併到開發分支,或者是合併回主分支,
並標上另一版本號的tag。
• 開此分支的目的在於開發分支上的成員可以繼續原本的
工作,而bug修復工作也同時由另外的成員來執行,使
得對彼此間的影響降到最低。
• 特別注意的是,若修補程式分支與發佈分支同時存在,
則當bug修補已完畢時,就不是合併回開發分支,而是
發佈分支。
GITFLOW FOR VISUAL STUDIO 2015
• http://mvc.tw/004O
VISUAL STUDIO 2015 UPDATE 2
結論
• Git 是一套成功的分散式版本控管。
• VSTS 提供一個強大的 DevOps 平台,Version Control 與 Git 可以無縫整合。
• Team Explorer 去除煩雜的指令,提供簡易介面與操作。
• Git + VSTS + Visual Studio 提供高生產力的開發作業流程。
• 進一步的 Git 需求,那麼請花點時間瞭解 Git 指令。
參考資料
• https://git-scm.com/book/zh-tw/v1
• https://msdn.microsoft.com/en-us/library/vs/alm/code/git/overview
• https://www.visualstudio.com/en-us/get-started/code/gitquickstart
• https://guides.github.com/introduction/flow/
• http://nvie.com/posts/a-successful-git-branching-model/
• http://git-tutorial.readthedocs.org/zh/latest/branchingmodel.html
• http://www.ruanyifeng.com/blog/2012/07/git.html
• http://huan-lin.blogspot.com/2012/04/git-ignore-file.html
• Book:http://books.gotop.com.tw/v_ACA021200

More Related Content

Viewers also liked

GNU AS簡介
GNU AS簡介GNU AS簡介
GNU AS簡介Wen Liao
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)Will Huang
 
千里之行,始於足下:動手寫自己的App
千里之行,始於足下:動手寫自己的App千里之行,始於足下:動手寫自己的App
千里之行,始於足下:動手寫自己的AppSmallr Huang
 
git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用Will Huang
 
基于Aws的dev ops实践指南 王毅
基于Aws的dev ops实践指南 王毅基于Aws的dev ops实践指南 王毅
基于Aws的dev ops实践指南 王毅Mason Mei
 
ChinaNetCloud - Aliyun Joint Event on Cloud Operations
ChinaNetCloud - Aliyun Joint Event on Cloud Operations ChinaNetCloud - Aliyun Joint Event on Cloud Operations
ChinaNetCloud - Aliyun Joint Event on Cloud Operations ChinaNetCloud
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Team foundation build 2017
Team foundation build 2017Team foundation build 2017
Team foundation build 2017Ming Man Chan
 
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀Wen Liao
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian OverviewAtlassian
 
Visual studio enterprise 2017 mobile by Russ Fustino
Visual studio enterprise 2017 mobile by Russ FustinoVisual studio enterprise 2017 mobile by Russ Fustino
Visual studio enterprise 2017 mobile by Russ FustinoRuss Fustino
 
The Latest and Greatest Products Overview
The Latest and Greatest Products OverviewThe Latest and Greatest Products Overview
The Latest and Greatest Products OverviewXpand IT
 
Seven habits of effective devops - DevOps Day - 02/02/2017
Seven habits of effective devops - DevOps Day - 02/02/2017Seven habits of effective devops - DevOps Day - 02/02/2017
Seven habits of effective devops - DevOps Day - 02/02/2017Clara Feuillet
 
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群Amazon Web Services
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with KubernetesOleg Chunikhin
 
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...Amazon Web Services
 
Overview of .Net Development on AWS
Overview of .Net Development on AWSOverview of .Net Development on AWS
Overview of .Net Development on AWSAmazon Web Services
 

Viewers also liked (20)

GNU AS簡介
GNU AS簡介GNU AS簡介
GNU AS簡介
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
 
千里之行,始於足下:動手寫自己的App
千里之行,始於足下:動手寫自己的App千里之行,始於足下:動手寫自己的App
千里之行,始於足下:動手寫自己的App
 
git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用
 
Git and Github
Git and GithubGit and Github
Git and Github
 
基于Aws的dev ops实践指南 王毅
基于Aws的dev ops实践指南 王毅基于Aws的dev ops实践指南 王毅
基于Aws的dev ops实践指南 王毅
 
ChinaNetCloud - Aliyun Joint Event on Cloud Operations
ChinaNetCloud - Aliyun Joint Event on Cloud Operations ChinaNetCloud - Aliyun Joint Event on Cloud Operations
ChinaNetCloud - Aliyun Joint Event on Cloud Operations
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git 版本控制 (使用教學)
Git 版本控制 (使用教學)Git 版本控制 (使用教學)
Git 版本控制 (使用教學)
 
Team foundation build 2017
Team foundation build 2017Team foundation build 2017
Team foundation build 2017
 
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian Overview
 
Visual studio enterprise 2017 mobile by Russ Fustino
Visual studio enterprise 2017 mobile by Russ FustinoVisual studio enterprise 2017 mobile by Russ Fustino
Visual studio enterprise 2017 mobile by Russ Fustino
 
The Latest and Greatest Products Overview
The Latest and Greatest Products OverviewThe Latest and Greatest Products Overview
The Latest and Greatest Products Overview
 
Seven habits of effective devops - DevOps Day - 02/02/2017
Seven habits of effective devops - DevOps Day - 02/02/2017Seven habits of effective devops - DevOps Day - 02/02/2017
Seven habits of effective devops - DevOps Day - 02/02/2017
 
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群
使用 Amazon Pinpoint 讓你的行動 App 更精準接觸客群
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with Kubernetes
 
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...
Enrich Your DevOps Environment: Tools for Accelerating and Integrating Your A...
 
Overview of .Net Development on AWS
Overview of .Net Development on AWSOverview of .Net Development on AWS
Overview of .Net Development on AWS
 

More from Bruce Chen

一個微信專案從0到000的效能調教
一個微信專案從0到000的效能調教一個微信專案從0到000的效能調教
一個微信專案從0到000的效能調教Bruce Chen
 
OWASP Top 10 (2013) 正體中文版
OWASP Top 10 (2013) 正體中文版OWASP Top 10 (2013) 正體中文版
OWASP Top 10 (2013) 正體中文版Bruce Chen
 
網站自動化測試
網站自動化測試網站自動化測試
網站自動化測試Bruce Chen
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)Bruce Chen
 
@Connect(); microsoft visual studio vnext & azure
@Connect(); microsoft visual studio vnext & azure@Connect(); microsoft visual studio vnext & azure
@Connect(); microsoft visual studio vnext & azureBruce Chen
 
輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2Bruce Chen
 
2014 Global Windows Bootcamp - 笑cc讓網站上雲端
2014 Global Windows Bootcamp - 笑cc讓網站上雲端2014 Global Windows Bootcamp - 笑cc讓網站上雲端
2014 Global Windows Bootcamp - 笑cc讓網站上雲端Bruce Chen
 

More from Bruce Chen (8)

一個微信專案從0到000的效能調教
一個微信專案從0到000的效能調教一個微信專案從0到000的效能調教
一個微信專案從0到000的效能調教
 
ReSharper
ReSharperReSharper
ReSharper
 
OWASP Top 10 (2013) 正體中文版
OWASP Top 10 (2013) 正體中文版OWASP Top 10 (2013) 正體中文版
OWASP Top 10 (2013) 正體中文版
 
網站自動化測試
網站自動化測試網站自動化測試
網站自動化測試
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
 
@Connect(); microsoft visual studio vnext & azure
@Connect(); microsoft visual studio vnext & azure@Connect(); microsoft visual studio vnext & azure
@Connect(); microsoft visual studio vnext & azure
 
輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2
 
2014 Global Windows Bootcamp - 笑cc讓網站上雲端
2014 Global Windows Bootcamp - 笑cc讓網站上雲端2014 Global Windows Bootcamp - 笑cc讓網站上雲端
2014 Global Windows Bootcamp - 笑cc讓網站上雲端
 

VSTS-Git with Visual Studio 入門教學

Editor's Notes

  1. 每個人都可以申請使用。 申請之後可以依照下面範例進行學習。
  2. 開啟一個新專案,Version Control 選擇 Git
  3. 連線至 VSTS 後,在 Team Explorer 選擇新增的專案
  4. 按下 Clone this repository,進行專案初始化的工作
  5. 新增專案,預設建立至 Clone this repository 目錄位置 記得勾選 add to source control
  6. https://guides.github.com/introduction/flow/ 點進去看一下。
  7. 目前只有 master 撰寫 commit message
  8. 如果你覺得下指令才是帥,那麼…
  9. 請先不要按 Sync
  10. Sync(同步) | Fetch(擷取) | Pull(提取) | Push(推送) 集中在 Sync 頁籤內。 按 Push 進行第一次同步。
  11. 新增任一個檔案; - 全部認可 - 全部認可與推送 - 全部認可與同步
  12. 選擇 commit and push
  13. 新增或修改些什麼
  14. https://www.visualstudio.com/en-us/get-started/code/git/pullrequest Git uses pull requests to include work completed in one branch into the another branch of the code, such as master.
  15. 以上參考:https://msdn.microsoft.com/en-us/library/vs/alm/code/git/overview
  16. https://www.visualstudio.com/en-us/get-started/code/git/pulling
  17. 原文:http://nvie.com/posts/a-successful-git-branching-model/ 簡單:http://www.juvenxu.com/2010/11/28/a-successful-git-branching-model/
  18. 分支策略說明:http://git-tutorial.readthedocs.org/zh/latest/branchingmodel.html