Git for Windows
Use TortoiseGit
Peter Chen
Agenda
- Local Work Flow
- New for Radar
- Get New Jira Issue
- Developing
- New Feature Completed or Bug Fixed
- Remote Work Flow
- On GitLab
- After Merge to Master
Local
Work
Flow
Local Work Flow
New for Radar
- Install Git
- Install TortoiseGit
- Clone
- Set bugtraq
- Set Remote
New for Radar
Install Git
Install TorotiseGit
Install
Git
- Distributed version control system
- Source: https://git-scm.com/
TortoiseGit
- Windows Shell Interface to Git
- Source: https://tortoisegit.org/
Install
New for Radar
Install Git
Install TorotiseGit
Clone
Clone
打開GitLab進入專案首頁按下Copy URL to clipboard
本地資料夾按右鍵點選`Git Clone...`
Clone
複製遠端檔案庫至本地端
New for Radar
Install Git
Install TorotiseGit
Clone
Set bugtraq
Set bugtraq
.git/config中加入[bugtraq]
Commit時可以填入Jira單號
Set bugtraq
追蹤Jira單號
New for Radar
Install Git
Install TorotiseGit
Clone
Set bugtraq
Set Remote
Set Remote
Set Remote URL
-
專案資料夾右鍵`TortoiseGit` => `Settings`
-
打開Remote頁籤
-
設定Clone的URL為origin remote的URL
New for Radar
Install Git
Install TorotiseGit
Clone
Set bugtraq
Set Remote
Local Work Flow
Get New Jira Issue
- Get Jira
- Branch
- Checkout
- Developing
Get New Jira Issue
Get Jira
Get Jira
Get New Jira Issue
Get Jira
Branch
Branch
在分支中解Jira單
-
專案資料夾右鍵`TortoiseGit` => `Create Branch...`
-
Branch Name格式: Jira單號/版本號
Get New Jira Issue
Get Jira
Branch
Checkout
- 專案資料夾右鍵`TortoiseGit` => ` Switch/Checkout... `
- 選取待解的Jira單號/版本號
查看目前所在的分支對資料夾按右鍵
Checkout
變換分支
Get New Jira Issue
Get Jira
Branch
Checkout
Developing
Local Work Flow
Developing
- Developing
- Pull
- Conflict
- Resolve
- Commit
Developing
Developing
Developing
Developing
Developing
Pull
Pull
本地的Program.cs是Hello World!
遠端的Program.cs已經被改成Hello Git!
Pull
遠端檔案庫檔案放至本地檔案庫並合併
- 資料夾按右鍵TortoiseGit => Pull...
- 同步遠端的master檔案至本地端
本地的Hello World!已經變成Hello Git!
Pull
Developing
Developing
Pull
Conflict
Conflict
Conflict
- 衝突情況發生於Pull時來源跟本地端的檔案內容不一致
- Pull為兩個指令的合併
- Fetch: 取得遠端檔案庫最新資料並於本地建立分支儲存
- Merge: 將Fetch所在的分支合併到目前的分支中
- Merge時會因兩個分支不一致導致Conflict
Developing
Developing
Pull
Conflict
Resolve
Resolve
Resolve Conflict
- 對發生衝突的檔案按右鍵Edit Conflicts
-
畫面說明
-
左上: 遠端檔案庫檔案
-
右上: 本地檔案庫檔案
-
下方: 合併後的檔案
-
-
區塊說明
- 橘色: 變更
- 紅色: 衝突
- 將Merge後的結果編輯在下方的檔案中
-
按下Save, 按下Mark as resolved
Developing
Developing
Pull
Conflict
Resolve
Commit
Commit
Commit
將檔案上到本地檔案庫
- 專案資料夾右鍵Git Commit -> [Jira單號/版本號]
- Commit時於右上角填入Jira單號
- 註1: 不要Commit在master
- 註2: 設定.gitignore將不需要commit的檔案(ex: Build之後產出的dll)排除
Developing
Developing
Pull
Conflict
Resolve
Commit
Local Work Flow
New Feature Completed
Bug Fixed
New Feature Completed
Bug Fixed
Local Test
Local Test
New Feature Completed
Bug Fixed
Local Test
Push Branch to Remote Repo
Push Branch to Remote Repo
- 專案資料夾右鍵TortoiseGit => Push…
- Remote填入Jira單號/版本號
GitLab上可以看到此分支
Push
將本地檔案庫推至遠端檔案庫中
New Feature Completed
Bug Fixed
Local Test
Push Branch to Remote Repo
Local Work Flow
Remote
Work
Flow
Remote Work Flow
On GitLab
- Merge Request
- Code Review
- Discussions?
- No: Merge to Master
- Yes: Back to Developing Flow
On GitLab
Merge Request
Merge Request
Merge Request
對遠端檔案庫Master提交合併請求
- 在GitLab上按下Merge Requests => Create/New Merge Request
- Title格式: Jira單號/版本號 Jira標題
- Description寫上此次Push的內容, 文尾加入事件編號
On GitLab
Merge Request
Code Review
Merge to Master
Discussions?
Back to Developing Flow
Yes
No
Remote Work Flow
After Merge to Master
- Online Test
- Problem?
- No: Resolve Jira
- Yes: Back to Developing Flow
After Merge to Master
Online Test
Problem?
Resolve Jira
Back to Developing FLow
Yes
No
Remote Work Flow
Resource
Thanks You
Git for Windows Use TortoiseGit
By Peter Chen
Git for Windows Use TortoiseGit
介紹Git在Windows使用小烏龜的方式
- 338