SlideShare a Scribd company logo
Version Control System
    Appendix B of Introduction to C Programming
             Author: Peter PH Chang




                                                  S
What is Version Control System?


S A.k.a. 版本控制系統

S 目的:
 S 個人使用:
   S 漸進式開發使用
   S 怕自己改爛之後改不回去本來可以動的狀況
 S 團隊開發:
   S 方便大家共同看一份程式碼,有效協同開發
   S 記錄是誰、在什麼時候、因為什麼原因改了那段程式碼
   S Branch(分支)開發,讓支線不影響主線
Type of VCS


S Copy-Paste
S Centralized Version Control System
S Distributed Version Control System
Type of VCS

S Copy Paste
 S   The most easy way to implement
 S   Awful way
 S   No comment message
 S   Not automically
 S   Wasting space
 S   No conflict solution
 S   No duplicate for backup
 S   不推薦使用此方法
VCS的流派

S Centralized VCS
 S Easy to implement
 S Learning curve is moderate
 S Cannot develop without network
 S Do everything by network. SLOW!
 S There is only one server. If it is
   broken, you loss everything
VCS的流派

S Distributed VCS
 S Learning curve is steep
 S Can work without network
 S Everyone has its clone. Don’t worry
   about server!
 S Easy to branch!
Well-known VCS
S Centralized VCS
 S CVS
 S Subversion (SVN)
 S Perforce
S Distributed VCS
 S git
 S Mercurial (Hg)
 S Bazaar
Distributed VCS: git
   分散式版本控制系統的範例




                       S
先來用用看


S 環境:MS Windows
 S UNIX系列亦可使用,但請參考附錄文件

S 安裝
 S msysgit
   S   Windows下git本體
   S   http://code.google.com/p/msysgit/downloads/list?q=net+installer
 S TortoiseGit
   S   git的圖形化使用者介面
   S   http://code.google.com/p/tortoisegit/wiki/Download?tm=2
Step1
Installation
Install msysgit - 1
Install msysgit - 2




會看到上面這個安裝檔,點兩下執行即可
Install msysgit - 4




   一直按Next即可安裝
Install msysgit - 5
Install msysgit - 6




 出現這個畫面就代表安裝完畢
Install Tortoise git - 1




                   看你是32-bit還是64-bit
                   選一個下載




               語言包,安裝完主程式
               之後可以安裝語言包讓
               介面變中文
Install Tortoise git - 2




會看到上面這個安裝檔,點兩下執行即可
Install Tortoise git - 3




     一直按Next即可安裝
Install Tortoise git - 4




有時候會跳出類似這個的警告視窗,按「是」即可繼續安裝
Install Tortoise git - 5




    看到這個畫面代表安裝完畢
Install Tortoise git - 6




如果你要用中文使用介面的話,可以安裝中文語言包
Step2
First commit
使用流程


S 一開始:
 S 利用git init來初始化git repo

S 新增檔案或修改程式碼後:
 S 利用git add來新增檔案到這次準備要傳到repo的檔案
 S 利用git commit來把檔案呈交到repo上
Initial Setting


S 先建一個資料夾,把程式碼放在裡面
Initial Setting


S 然後在裡面的程式碼檔案寫程式
Create a new repo

S 在資料夾上按右鍵,選「Git在此建立倉儲」(Git create repo )
Create a new repo

S 不要設為存倉儲
Create a new repo

S 按Proceed,忽略該資料夾當中有其他檔案
Create a new repo

S 看到這個畫面就代表已經建立一個新的Git repo
在程式碼檔案上按右鍵,
選TortoiseGit裡面的
「增加」,讓他增加到
這次準備要commit的檔
案中
Add file

S 勾選你要新增的檔案
Add file

S 這樣就完成add file了,但是還需要commit才真正呈交到repo上
Commit file

S 按下Commit鍵
Commit files

S 若你是剛灌git,還沒設定name與email的話,他會問你要不要現
 在設定,選Yes來設定
Commit files

S 若你是剛灌git,還沒設定name與email的話,他會問你要不要現
 在設定,選Yes來設定
Commit files
Commit files




S 在「記錄訊息」裡面填寫這次Commit的修改後,就可按「確定」來
 Commit
Commit files




S 出現這個畫面就代表Commit完成
Git diff




S 我們再來修改裡面的程式碼看看,在第六行加一個新的printf
Git diff




S 然後在資料夾按右鍵去「TortoiseGit」裡面選擇「比對差異」
Git diff




S 會出現這個視窗,顯示說現在的檔案和最後一次Commit差在哪裡

S 在檔案名稱上面連點兩下,就可以詳細看檔案差異
Git diff
改爛了…怎麼改回去
改爛了…怎麼改回去




S 把要回復的檔案勾選起來後,按「確定」
改爛了…怎麼改回去




S 改好了!我們看一下那個被改過的檔案
改爛了…怎麼改回去




S 已經改回上一次commit時候的狀況
Another way: CLI

S 新建repo
  S git init

S 新增檔案、呈交到repo
  S git add .
  S git commit –m “Commit message”

S 查看Git記錄
  S git log

S 查看程式碼差異
  S git diff 5d09
  S git diff 5d09 ab01
Git Server




             S
GitHub


S 可自己架git server
  S 在Linux、Mac上比較好架
  S Windows上架git server較為複雜

S 但我們有GitHub!
  S Easy to create public repo
  S If you have .edu mail, you can get right to create private
     repo for free during the two years
     S   https://github.com/edu
GitHub
GitHub
GitHub

S 複製一份下來!
 S git clone REPO的網址
 S 在TortoiseGit上,新增一個資料夾按右鍵,有個clone倉儲的
   按鍵,按下去之後,把REPO的網址填入,即可自server複製
   下來

S 和git server溝通的方式
 S 自server上取得新的版本
   S   git pull
 S 把改好的版本送上server
   S   git push
Reference




            S
Reference


S Git tutorial:http://www.slideshare.net/ihower/git-tutorial-
  13695342

S 寫給大家的Git教學:http://www.slideshare.net/littlebtc/git-
  5528339

S Git教學:初學者使用心得分享(Windows) :
  http://www.mrmu.com.tw/2011/05/06/git-tutorial-for-
  beginner/

More Related Content

DOCX
OpenGeo Suite试用报告
PDF
Git 入门实战
PDF
Git Flow基礎操作與觀念介紹
PDF
Snap打包:軟體使用者與上游的♥多元成家♥
PDF
Distributed Version Control (DVCS) With Mercurial
PDF
Version Control Systems - ArabNet Beirut 2014 - Dani Arnaout
ODP
Intro To Version Control
KEY
An introduction to Version Control Systems
OpenGeo Suite试用报告
Git 入门实战
Git Flow基礎操作與觀念介紹
Snap打包:軟體使用者與上游的♥多元成家♥
Distributed Version Control (DVCS) With Mercurial
Version Control Systems - ArabNet Beirut 2014 - Dani Arnaout
Intro To Version Control
An introduction to Version Control Systems

Viewers also liked (7)

PPTX
01 - Introduction to Version Control
KEY
The everyday developer's guide to version control with Git
PDF
A brief introduction to version control systems
PDF
What is version control software and why do you need it?
PDF
Version Control with SVN
ODP
Introduction to Version Control
01 - Introduction to Version Control
The everyday developer's guide to version control with Git
A brief introduction to version control systems
What is version control software and why do you need it?
Version Control with SVN
Introduction to Version Control
Ad

Similar to Introduction to Version Control System for Windows (20)

PPTX
工程師必備第一工具 - Git
PDF
Git and Github basic with SourceTree
PPT
Git簡報
PDF
Git in a nutshell
PPTX
Git and git hub
PPT
Cocoa on Rails 4th
PDF
Visual Studio Code 快速上手指南
PDF
COSCUP 2015 開源之道-Git工作坊教學簡報
PDF
版本控制 使用Git & git hub
PPTX
Git & git flow
PPT
Git flow
PDF
Git+使用教程
PDF
Git
ODP
Git 程式碼版本控制軟體介紹
PDF
寫給大家的 Git 教學
PDF
First meetingwithgit
PDF
Learning to Use Git | WeiYuan
PDF
Introduction to git
PDF
AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]
PPTX
大家應該都要會的工具 Git 從放棄到會用2-分支篇
工程師必備第一工具 - Git
Git and Github basic with SourceTree
Git簡報
Git in a nutshell
Git and git hub
Cocoa on Rails 4th
Visual Studio Code 快速上手指南
COSCUP 2015 開源之道-Git工作坊教學簡報
版本控制 使用Git & git hub
Git & git flow
Git flow
Git+使用教程
Git
Git 程式碼版本控制軟體介紹
寫給大家的 Git 教學
First meetingwithgit
Learning to Use Git | WeiYuan
Introduction to git
AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]
大家應該都要會的工具 Git 從放棄到會用2-分支篇
Ad

Introduction to Version Control System for Windows