. . . . . .
.
.
. ..
.
.
淺談 Source Control Management
yen3
長庚大學資訊工程學系
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 1 / 23
. . . . . .
About
.. About Slide
專題程式開發簡報,陸續有其他介紹
感謝李春良老師專題指導,使得這一系列簡報得己誕生
感謝 Josh Ko 在簡報排版上的指導與協助
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 2 / 23
. . . . . .
About
.. About Author
Computer Science Student
Blog: No title, no thinking, no meaning
E-mail: yen3rc 在 gmail 答康
隨手書寫生活
C, C++, Java, Haskell, LATEX
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 3 / 23
. . . . . .
Outline
.
..1 About
.
..2 Introduction
What?
Why?
.
..3 Source Control Management
Environment
Concept
branch
Software
.
..4 Software
git
Google Code with svn
Visual Studio.net With svn
.
..5 Conclusion
Conclusion
Reference
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 4 / 23
. . . . . .
Introduction What?
.. What is Source Control Management?
Source Control Management(SCM) 為 Open Source
界常見的專案開發工具.
針對 plain text ,比較與先前的檔案差異,
儲存修改之處。
若是架在 Server 上,支援多人上傳協同開發。
常見軟體有 svn, git, ...等等。
在常見的 Software IDE(Eclipse, NetBeans, vim XD, VS.net) 皆有
plug-in 支援
Visual Studio.net Team Suite 內建版本控制(不建議)
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 5 / 23
. . . . . .
Introduction Why?
.. Why do we need Source Control Management?
當寫程式需要備份時· · ·
當需要協同專案開發時· · ·
寫文件需要比較前後版本時· · ·
當需要寫情書時(大誤)· · ·
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 6 / 23
. . . . . .
Introduction Why?
.. How about Binary File?
硬碟夠大的話· · ·
Word(.doc) → binary file ( 考慮 LATEX系列 XD?)
程式碼 → plain text (LATEX檔也是 plain text 喔 XD)
寫情書的話 → 記事本 + 版本管理 XD
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 7 / 23
. . . . . .
Source Control Management Environment
.. Environment
Client-Server Architecture(client and server can be in the same
computer.)
Main Concept: diff, line-by-line comparing
It would add something file with SCM in your file of managing.
For project development, you could need a server(with ip) to upload
your file.
For personal development, you could use only one computer to finish
anything what you want.
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 8 / 23
. . . . . .
Source Control Management Environment
.. diff: comparing two files
01.cpp
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <iterator>
template<class RAI>
void bubble_sort(RAI begin, RAI end){
for(RAI i=begin; i!=end; ++i){
for(RAI j=i+1; j!=end; ++j){
if(*i>*j) std::swap(*i, *j);
}
}
}
int main(int argc, char** argv){
std::vector<int> u(10, 0);
std::generate(u.begin(),
u.end(), rand);
bubble_sort(u.begin(), u.end());
std::copy(u.begin(), u.end(),
std::ostream_iterator<int>
(std::cout, "n"));
}
02.cpp
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <iterator>
int main(int argc, char** argv){
std::vector<int> u(10, 0);
std::generate(u.begin(),
u.end(), rand);
std::sort(u.begin(), u.end());
std::copy(u.begin(), u.end(),
std::ostream_iterator<int>
(std::cout, "n"));
}
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 9 / 23
. . . . . .
Source Control Management Environment
.. java.util.List<E>
.
For Example: java.util.list < E >
..
.
. ..
.
.
Macinotosh-3:bubble yen3$ diff 01.cpp 02.cpp
7,15d6
< template<class RAI>
< void bubble_sort(RAI begin, RAI end){
< for(RAI i=begin; i!=end; ++i){
< for(RAI j=i+1; j!=end; ++j){
< if(*i>*j) std::swap(*i, *j);
< }
< }
< }
<
19c10
< bubble_sort(u.begin(), u.end());
---
> std::sort(u.begin(), u.end());
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 10 / 23
. . . . . .
Source Control Management Concept
.. Noun Explanation
1
Repository: 管理的 project ,有可能是一個檔案到
一個或數個資料夾
Pull/Push/Checkout: 下載
Branch: 上傳時,建立新的分支版本
Merge: 把不同的分支版本合併成 Master version
Conflict: 版本衝突
Commit: 上傳
Revert: 復原為先前的版本
1
我愛git, jserv
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 11 / 23
. . . . . .
Source Control Management Concept
.. Requirement
2
軟體中設定自己的名字與 email,方便辨別,以負責
你的上傳
送交 (commit) 的程式碼必須是完整、可以執行、
沒有錯誤的程式碼。
送交程式碼時,請於備註欄位註明:更動過的檔案、
檔案做了哪些修改等細節。
在修改程式前,務必將程式更新 (update) 至最新
版本。
送交程式時若發生「衝突」,請解決衝突後再送交。
2
Zeroplex生活隨筆-SVN rules, Zeroplex
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 12 / 23
. . . . . .
Source Control Management branch
.. branch
衝突和分支不同
協同開發時所產生的情境
多人同時開發於同一檔案時,或者是目前已經足夠
穩定,想要開發新版時
若是新的分支足夠穩定,即可與 master branch 合併
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 13 / 23
. . . . . .
Source Control Management Software
.. Which Software is Source Control Management?
cvs: 對不起,我沒用過 XD
svn: 最常見的 SCM
git: 後起之秀,改善 svn 許多缺點
darcs: Haskell寫成的 SCM(比 git 還輕巧...Orz)
by yourself: 好主意!
plug-in:大多以 svn 為主,請自行 Google XD
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 14 / 23
. . . . . .
Software git
.. git
由 Linus Torvald 在2005年後發展,流行於許多
大型專案管理。
以速度快佔用體積小聞名。
IDE 較少 plug-in
簡報: Jserv’s Blog: 我愛git
教學: 國網中心blog: git原始碼管理
Server建置: walkingice’s blog: [Geek] Git and Gitweb
Eclipse with Git Plug-in: yen3’s blog: Intstall git plug-in in Eclipse
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 15 / 23
. . . . . .
Software git
.. Screenshot
現場實際操作
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 16 / 23
. . . . . .
Software Google Code with svn
.. Google Code wtih svn
現成的 svn server
若無授權限制 (GPL, BSD · · · )及程式碼公開問題,
Google Code 是一選擇
每個 Repository 大小限制 100mb
教學: ericsk’s blog :
用 Subversion 跟 Google Code 作版本控制(一)
教學: ericsk’s blog :
用 Subversion 跟 Google Code 作版本控制(二)
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 17 / 23
. . . . . .
Software Google Code with svn
.. Screenshot
現場實際操作
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 18 / 23
. . . . . .
Software Visual Studio.net With svn
.. Visual Studio.net With svn
Client: Visual Studio.net with AnhkSVN(expression edition 無法使用)
Server 可選擇架在 Google Code(現成 svn server)
Server: IIS + VisualSVN or Apache + VisualSVN (Windows
Enviornment)
簡單教學: yen3’s blog: Visual Studio + svn
並不是一個很穩定的解決方案,或許可以
考慮 Team Suite Solution(我沒用過XD)
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 19 / 23
. . . . . .
Software Visual Studio.net With svn
.. Screenshot
現場實際操作
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 20 / 23
. . . . . .
Software Visual Studio.net With svn
.. Using Experience
選一個最適合自己環境的 SCM
請一定要傳能動的程式上上去· · ·
上傳一定要記得寫註解,不寫· · ·
如果分工足夠精確,分別撰寫不同檔案,發生衝突
問題機會較小。
在 Open Source 界, SCM rules 需被嚴格遵守。
SCM也可視為一種程式碼備份方法
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 21 / 23
. . . . . .
Conclusion Conclusion
.. Conclusion
在專案開發下,可省下許多合併程式碼的時間。
工具只是輔助開發程式,而核心仍是程式設計。
這是只是專題程式開發學習的第一步。
多看 Open Source 界在做什麼,會學到很多有趣
的事。
防止程式碼洗掉的好選擇XD。
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 22 / 23
. . . . . .
Conclusion Reference
.. Reference
svn: http://subversion.tigris.org/
git: http://git-scm.com/
darcs: http://darcs.net/
Google Code: http://code.google.com
AnhkSVN: http://ankhsvn.open.collab.net/
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 23 / 23

漫談 Source Control Management

  • 1.
    . . .. . . . . . .. . . 淺談 Source Control Management yen3 長庚大學資訊工程學系 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 1 / 23
  • 2.
    . . .. . . About .. About Slide 專題程式開發簡報,陸續有其他介紹 感謝李春良老師專題指導,使得這一系列簡報得己誕生 感謝 Josh Ko 在簡報排版上的指導與協助 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 2 / 23
  • 3.
    . . .. . . About .. About Author Computer Science Student Blog: No title, no thinking, no meaning E-mail: yen3rc 在 gmail 答康 隨手書寫生活 C, C++, Java, Haskell, LATEX yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 3 / 23
  • 4.
    . . .. . . Outline . ..1 About . ..2 Introduction What? Why? . ..3 Source Control Management Environment Concept branch Software . ..4 Software git Google Code with svn Visual Studio.net With svn . ..5 Conclusion Conclusion Reference yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 4 / 23
  • 5.
    . . .. . . Introduction What? .. What is Source Control Management? Source Control Management(SCM) 為 Open Source 界常見的專案開發工具. 針對 plain text ,比較與先前的檔案差異, 儲存修改之處。 若是架在 Server 上,支援多人上傳協同開發。 常見軟體有 svn, git, ...等等。 在常見的 Software IDE(Eclipse, NetBeans, vim XD, VS.net) 皆有 plug-in 支援 Visual Studio.net Team Suite 內建版本控制(不建議) yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 5 / 23
  • 6.
    . . .. . . Introduction Why? .. Why do we need Source Control Management? 當寫程式需要備份時· · · 當需要協同專案開發時· · · 寫文件需要比較前後版本時· · · 當需要寫情書時(大誤)· · · yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 6 / 23
  • 7.
    . . .. . . Introduction Why? .. How about Binary File? 硬碟夠大的話· · · Word(.doc) → binary file ( 考慮 LATEX系列 XD?) 程式碼 → plain text (LATEX檔也是 plain text 喔 XD) 寫情書的話 → 記事本 + 版本管理 XD yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 7 / 23
  • 8.
    . . .. . . Source Control Management Environment .. Environment Client-Server Architecture(client and server can be in the same computer.) Main Concept: diff, line-by-line comparing It would add something file with SCM in your file of managing. For project development, you could need a server(with ip) to upload your file. For personal development, you could use only one computer to finish anything what you want. yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 8 / 23
  • 9.
    . . .. . . Source Control Management Environment .. diff: comparing two files 01.cpp #include <iostream> #include <algorithm> #include <vector> #include <cstdlib> #include <iterator> template<class RAI> void bubble_sort(RAI begin, RAI end){ for(RAI i=begin; i!=end; ++i){ for(RAI j=i+1; j!=end; ++j){ if(*i>*j) std::swap(*i, *j); } } } int main(int argc, char** argv){ std::vector<int> u(10, 0); std::generate(u.begin(), u.end(), rand); bubble_sort(u.begin(), u.end()); std::copy(u.begin(), u.end(), std::ostream_iterator<int> (std::cout, "n")); } 02.cpp #include <iostream> #include <algorithm> #include <vector> #include <cstdlib> #include <iterator> int main(int argc, char** argv){ std::vector<int> u(10, 0); std::generate(u.begin(), u.end(), rand); std::sort(u.begin(), u.end()); std::copy(u.begin(), u.end(), std::ostream_iterator<int> (std::cout, "n")); } yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 9 / 23
  • 10.
    . . .. . . Source Control Management Environment .. java.util.List<E> . For Example: java.util.list < E > .. . . .. . . Macinotosh-3:bubble yen3$ diff 01.cpp 02.cpp 7,15d6 < template<class RAI> < void bubble_sort(RAI begin, RAI end){ < for(RAI i=begin; i!=end; ++i){ < for(RAI j=i+1; j!=end; ++j){ < if(*i>*j) std::swap(*i, *j); < } < } < } < 19c10 < bubble_sort(u.begin(), u.end()); --- > std::sort(u.begin(), u.end()); yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 10 / 23
  • 11.
    . . .. . . Source Control Management Concept .. Noun Explanation 1 Repository: 管理的 project ,有可能是一個檔案到 一個或數個資料夾 Pull/Push/Checkout: 下載 Branch: 上傳時,建立新的分支版本 Merge: 把不同的分支版本合併成 Master version Conflict: 版本衝突 Commit: 上傳 Revert: 復原為先前的版本 1 我愛git, jserv yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 11 / 23
  • 12.
    . . .. . . Source Control Management Concept .. Requirement 2 軟體中設定自己的名字與 email,方便辨別,以負責 你的上傳 送交 (commit) 的程式碼必須是完整、可以執行、 沒有錯誤的程式碼。 送交程式碼時,請於備註欄位註明:更動過的檔案、 檔案做了哪些修改等細節。 在修改程式前,務必將程式更新 (update) 至最新 版本。 送交程式時若發生「衝突」,請解決衝突後再送交。 2 Zeroplex生活隨筆-SVN rules, Zeroplex yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 12 / 23
  • 13.
    . . .. . . Source Control Management branch .. branch 衝突和分支不同 協同開發時所產生的情境 多人同時開發於同一檔案時,或者是目前已經足夠 穩定,想要開發新版時 若是新的分支足夠穩定,即可與 master branch 合併 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 13 / 23
  • 14.
    . . .. . . Source Control Management Software .. Which Software is Source Control Management? cvs: 對不起,我沒用過 XD svn: 最常見的 SCM git: 後起之秀,改善 svn 許多缺點 darcs: Haskell寫成的 SCM(比 git 還輕巧...Orz) by yourself: 好主意! plug-in:大多以 svn 為主,請自行 Google XD yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 14 / 23
  • 15.
    . . .. . . Software git .. git 由 Linus Torvald 在2005年後發展,流行於許多 大型專案管理。 以速度快佔用體積小聞名。 IDE 較少 plug-in 簡報: Jserv’s Blog: 我愛git 教學: 國網中心blog: git原始碼管理 Server建置: walkingice’s blog: [Geek] Git and Gitweb Eclipse with Git Plug-in: yen3’s blog: Intstall git plug-in in Eclipse yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 15 / 23
  • 16.
    . . .. . . Software git .. Screenshot 現場實際操作 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 16 / 23
  • 17.
    . . .. . . Software Google Code with svn .. Google Code wtih svn 現成的 svn server 若無授權限制 (GPL, BSD · · · )及程式碼公開問題, Google Code 是一選擇 每個 Repository 大小限制 100mb 教學: ericsk’s blog : 用 Subversion 跟 Google Code 作版本控制(一) 教學: ericsk’s blog : 用 Subversion 跟 Google Code 作版本控制(二) yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 17 / 23
  • 18.
    . . .. . . Software Google Code with svn .. Screenshot 現場實際操作 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 18 / 23
  • 19.
    . . .. . . Software Visual Studio.net With svn .. Visual Studio.net With svn Client: Visual Studio.net with AnhkSVN(expression edition 無法使用) Server 可選擇架在 Google Code(現成 svn server) Server: IIS + VisualSVN or Apache + VisualSVN (Windows Enviornment) 簡單教學: yen3’s blog: Visual Studio + svn 並不是一個很穩定的解決方案,或許可以 考慮 Team Suite Solution(我沒用過XD) yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 19 / 23
  • 20.
    . . .. . . Software Visual Studio.net With svn .. Screenshot 現場實際操作 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 20 / 23
  • 21.
    . . .. . . Software Visual Studio.net With svn .. Using Experience 選一個最適合自己環境的 SCM 請一定要傳能動的程式上上去· · · 上傳一定要記得寫註解,不寫· · · 如果分工足夠精確,分別撰寫不同檔案,發生衝突 問題機會較小。 在 Open Source 界, SCM rules 需被嚴格遵守。 SCM也可視為一種程式碼備份方法 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 21 / 23
  • 22.
    . . .. . . Conclusion Conclusion .. Conclusion 在專案開發下,可省下許多合併程式碼的時間。 工具只是輔助開發程式,而核心仍是程式設計。 這是只是專題程式開發學習的第一步。 多看 Open Source 界在做什麼,會學到很多有趣 的事。 防止程式碼洗掉的好選擇XD。 yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 22 / 23
  • 23.
    . . .. . . Conclusion Reference .. Reference svn: http://subversion.tigris.org/ git: http://git-scm.com/ darcs: http://darcs.net/ Google Code: http://code.google.com AnhkSVN: http://ankhsvn.open.collab.net/ yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 23 / 23