SlideShare une entreprise Scribd logo
1  sur  54
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/

Contenu connexe

En vedette

01 - Introduction to Version Control
01 - Introduction to Version Control01 - Introduction to Version Control
01 - Introduction to Version ControlSergii Shmarkatiuk
 
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
 
A brief introduction to version control systems
A brief introduction to version control systemsA brief introduction to version control systems
A brief introduction to version control systemsTim Staley
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?Leonid Mamchenkov
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVNPHPBelgium
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlJeremy Coates
 

En vedette (7)

01 - Introduction to Version Control
01 - Introduction to Version Control01 - Introduction to Version Control
01 - Introduction to Version Control
 
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
 
A brief introduction to version control systems
A brief introduction to version control systemsA brief introduction to version control systems
A brief introduction to version control systems
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVN
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 

Similaire à Introduction to Version Control System for Windows

工程師必備第一工具 - Git
工程師必備第一工具 - Git工程師必備第一工具 - Git
工程師必備第一工具 - GitAlan Tsai
 
Git and Github basic with SourceTree
Git and Github basic with SourceTreeGit and Github basic with SourceTree
Git and Github basic with SourceTreeChu-Siang Lai
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshellNelson Tai
 
Git and git hub
Git and git hubGit and git hub
Git and git hub唯 李
 
Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Shengyou Fan
 
COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報Bachue Zhou
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub維佋 唐
 
Git & git flow
Git & git flowGit & git flow
Git & git flowAmo Wu
 
Git flow
Git flowGit flow
Git flowshaokun
 
Git+使用教程
Git+使用教程Git+使用教程
Git+使用教程gemron
 
Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹Git 程式碼版本控制軟體介紹
Git 程式碼版本控制軟體介紹PingLun Liao
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學littlebtc
 
First meetingwithgit
First meetingwithgitFirst meetingwithgit
First meetingwithgitRhythm Sun
 
Learning to Use Git | WeiYuan
Learning to Use Git | WeiYuanLearning to Use Git | WeiYuan
Learning to Use Git | WeiYuanWei-Yuan Chang
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to gitBo-Yi Wu
 
AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]
AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]
AI 魔法師 - 繪圖詠唱初階班 (Stable Diffusion 101) @交大動畫社 [2023/3/13]Edison Lee
 
大家應該都要會的工具 Git 從放棄到會用2-分支篇
大家應該都要會的工具 Git   從放棄到會用2-分支篇大家應該都要會的工具 Git   從放棄到會用2-分支篇
大家應該都要會的工具 Git 從放棄到會用2-分支篇Alan Tsai
 

Similaire à Introduction to Version Control System for Windows (20)

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

Introduction to Version Control System for Windows