chw2054 / blog

任不重,道不遠,意不深

[轉載] SVN 基本指令教學

  ·

SVN 的基本指令介紹, 主要參考自下述:

主要 SubTrain 的 PPT 前面頁數看一看, 基礎就大概都知道了, 後面頁數太進階了, 目前用不到, 以後再看. XD

PS: 如果不知道 SVN 是什麼, 可見此文: 淺談版本控制系統, 裡面連結檔案看完, 應該就很清楚了 :)

先來看 SVN Trunk/Tags/Branches 目錄 的 架構 和 用途:(英文說明轉載自 SubTrain PPT)

  • trunk: Main line of development(主幹, 主要開發都由在 trunk)
  • tags: Releases (想要 Release 的時後, 就標個 Tag, 以後可以依 Tag 來找回之前版本的資料)
  • branches: Preparation of release, bug fixing(分支, 可以將某些功能切出來, 或者 bug fix 等切成分支, 等做完後再用 Merge 合併回來)

SVN 基本功能:

Import: 將整個 project_directory 的資料 import 進 svn 裡面

  • svn import project_directory http://DOMAIN/svn_project
  • svn import project_directory file:///SVN_PATH/svn_project

Checkout: (checkout 可簡寫成 co), 將資料 checkout 回來

  • svn co http://SVN_PATH/svn_project
  • svn co file:///SVN_PATH/svn_project
  • svn co -r 12 file:///var/lib/svn/dev/projects # 出第12版的 projcets code

List: (list 可簡寫成 ls), 看上面有哪些檔案/資料

  • svn ls http://SVN_PATH/svn_project
  • svn ls file:///SVN_PATH/svn_project

Update: (update 可簡寫成 up), 將目前資訊更新成 SVN 線上最新版本.

  • SVN_CHECKOUT_DIR$ svn up
Commit: (commit 可簡寫成 ci), 將目前所做的修改 commit 回 svn
  • SVN_CHECKOUT_DIR$ svn ci
Status: (status 可簡寫成 st), 看目前檔案/結構 跟 SVN 線上的版本有哪些不同
  • SVN_CHECKOUT_DIR$ svn st
Add: 將此 檔案/目錄 新增進 svn
  • SVN_CHECKOUT_DIR$ svn add filename 或 svn add directory
MV: 改檔名, 並且此檔案之前紀錄還要繼續留下
  • SVN_CHECKOUT_DIR$ svn mv filename new_filename
Revert: 還原這次的修改, 回到前一版的檔案狀態(未 commit 前可用)
  • SVN_CHECKOUT_DIR$ svn revert [file | directory]

SVN 檔案狀態資訊:

  • ?: 此檔案不存在 SVN 裡面
  • A: 此次新增的檔案
  • C: 此檔案已經有人改過, 合併不成功, 需要人工介入
  • D: 此次移除的檔案
  • M: 此檔案有修改過
  • U: 此檔案有被更新過

再來是比較進階一點點, 下述範例轉載自 SubTrain 的教學 PPT:

建立一個 branch

  • svn copy http://svnserver/calc/trunk http://svnserver/calc/branches/my-calc-branch -m 'create a branch'

建立 Release Tags:

  • svn copy http://svnserver/calc/trunk http://svnserver/calc/tags/Release-1.0.0 -m 'create Release tags for Release 1.0.0'

合併兩個版本的檔案 # 參考自: 用 Subversion 的 Merge 來 Undo

  • svn merge -r REV1:REV2 {path/to/workingcopy}
  • (UNDO) svn merge -r 1234:1233 . .
  • (MERGE)svn merge -r 1233:1234 . .
  • svn merge --dry-run -r 343:344 http://svn.example.com/repos/calc/trunk
有 "C" 狀態處理完後, 用 resolved 將自動產生的檔案刪除, 才能正常 commit:
  • svn resolved filename # 這樣子下就會把自動產生 diff 等的檔案刪除

找版本間有什麼不同 diff:

  • svn diff # 自動以現在檔案跟 SVN 內最新版做 diff
  • svn diff -r9237:9238
Info: 列出現在路徑, 版本編號, 最後一次修改日期 ... 等資訊
  • svn info

Log: 如果沒輸入參數, 預設會把所有 commit log 都列出來

  • svn log

Propset (propset, pset, ps): 版本控制都有些特殊 Keyword 設定, 如 Id 就是最常用的, 設定方法如下:

  1. 在檔案內找地方加入 $Id$
  2. 設定此檔案要能吃 Id 的 Keyword: svn ps svn:keywords 'Id' filename (只需設一次即可, 之後就不用再設)
  3. svn ci 後, $Id$ 會自動代換成 $Id:filename 編號 年月日時分秒 username $ 的資訊
  4. svn help ps 可以看到有哪些 Keyword 可以用, 即 Keyword 的說明.(ex: URL, Author, Date, Rev, Id 等.)

其它 SVN Client:

SVK 相關介紹:

其它相關網頁

18 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

It even contributes pollution to the environment aand most of all,
it can damage the lungs of the human body. The hazard of traditional tobacco cigarettes has been preached to no end over time.
There is no lingering odor on the interior of the car because there is no smoke.


Feel free to surf to my website sigaretta elettronica shop

Anonymous said...

I visited various web sites except the audio feature for audio songs
current at this site is actually fabulous.



Also visit my blog: brooklyn condominium inspection (youtube.com)

Anonymous said...

Excellent blog right here! Also your website a lot up very fast!

What host are you the use of? Can I am getting your affiliate link on your host?
I want my web site loaded up as fast as yours lol

Here is my site: http://Top.Tessasarcade.Info/

Anonymous said...

Generally, the system needs to be pumped out for every 1 to 3 years.
Then off course, to keep your septic system in proper
running order it's always advisable to get
a Septic Tank Pumping done every three to five years. Typically,
50-80% of household wastewater is greywater, the rest are from the toilets or contaminated greywater.


Feel free to surf to my blog ... http://76.108.202.25/

Anonymous said...

Heya i am for the first time here. I came across this board and I find It really useful & it helped me out much.

I hope to give something back and help others like you aided me.


Take a look at my weblog ... costa rica snook fishing videos

Anonymous said...

Attractive section of content. I just stumbled upon your weblog
and in accession capital to assert that I acquire actually enjoyed account your
blog posts. Any way I will be subscribing to your augment and even I achievement you
access consistently fast.

My page: download witcher 3 online

Anonymous said...

Hmm it looks like your blog ate my first comment (it was extremely
long) so I guess I'll just sum it up what I had written and say,
I'm thoroughly enjoying your blog. I as well am an aspiring blog
writer but I'm still new to everything. Do you have any recommendations for
novice blog writers? I'd definitely appreciate it.


my blog: aspergers in love

Anonymous said...

Actually, one of the main reasons why this is considered as relevant
is because there are a multitude of people that come to pass, stay
or linger within subways. You'll come under fire from
a number of ranged attackers, and at least two that will lob
fire at you. When you pick the opposite you have Southwest Airlines.


my site ... Subway Surf Hack

Anonymous said...

When I originally commented I appear to have clicked on the -Notify
me when new comments are added- checkbox and from now on whenever a comment is added I
get four emails with the same comment. Perhaps there is a means you can remove me
from that service? Kudos! www.cats.hintcenter.com

Look into my web page ... cat health problems

Anonymous said...

Wow, that's what I was looking for, what a data!
existing here at this weblog, thanks admin of this site.

Here is my web-site :: war of mercenaries cheat ()

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

I just could not go away your website before
suggesting that I extremely enjoyed the usual info a person supply in your guests?
Is going to be back continuously to investigate cross-check new posts

Feel free to visit my site ... http://bestwoocommercethemes.blogspot.com/2014/05/great-advice-about-wordpress-that.html

Anonymous said...

Hi! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing months
of hard work due to no data backup. Do you have any methods to prevent hackers?


Check out my webpage; diy home improvement ideas, http://www.homeimprovementdaily.com/,

Anonymous said...

After exploring a handful of the blog articles on your web page, I
really appreciate your way of writing a blog.

I book marked it to my bookmark website list and will be checking back soon.
Please visit my web site as well and tell me what you think.


Also visit my webpage; http://coquetaclub.blogspot.com/2010/08/girls-nite-out-one-more-time.html

Anonymous said...

If you want to get a great deal from this post then you have to
apply such techniques to your won blog.

My web page :: חיים מנעולים באזור ירושלים