Upload
yen3-chao
View
1.003
Download
3
Tags:
Embed Size (px)
DESCRIPTION
漫談 Source Control Management - 以 svn, git 為例,及在 Google Code 上的應用。
Citation preview
. . . . . .
.
.. ..
.
.
淺談 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 StudentBlog: No title, no thinking, no meaningE-mail: yen3rc 在 gmail 答康隨手書寫生活
C, C++, Java, Haskell, LATEX
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 3 / 23
. . . . . .
Outline
.. .1 About
.. .2 IntroductionWhat?Why?
.. .3 Source Control ManagementEnvironmentConceptbranchSoftware
.. .4 SoftwaregitGoogle Code with svnVisual Studio.net With svn
.. .5 ConclusionConclusionReference
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 samecomputer.)Main Concept: diff, line-by-line comparingIt would add something file with SCM in your file of managing.For project development, you could need a server(with ip) to uploadyour file.For personal development, you could use only one computer to finishanything 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.cpp7,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 versionConflict: 版本衝突Commit: 上傳Revert: 復原為先前的版本
1我愛git, jservyen3 (長庚大學資訊工程學系) 淺談 Source Control Management 11 / 23
. . . . . .
Source Control Management Concept
.. Requirement
2
軟體中設定自己的名字與 email,方便辨別,以負責你的上傳
送交 (commit) 的程式碼必須是完整、可以執行、沒有錯誤的程式碼。
送交程式碼時,請於備註欄位註明:更動過的檔案、
檔案做了哪些修改等細節。
在修改程式前,務必將程式更新 (update) 至最新版本。
送交程式時若發生「衝突」,請解決衝突後再送交。
2Zeroplex生活隨筆-SVN rules, Zeroplexyen3 (長庚大學資訊工程學系) 淺談 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: 對不起,我沒用過 XDsvn: 最常見的 SCMgit: 後起之秀,改善 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 GitwebEclipse 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 (WindowsEnviornment)簡單教學: 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.comAnhkSVN: http://ankhsvn.open.collab.net/
yen3 (長庚大學資訊工程學系) 淺談 Source Control Management 23 / 23