找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 14078|回复: 1

SVN 基本的用法

[复制链接]
发表于 2009-11-30 23:30:06 | 显示全部楼层 |阅读模式 IP:江苏扬州
The typical work cycle looks like this:
1. Update your working copy.
   ? svn update
2. Make changes.
   ? svn add
   ? svn delete
   ? svn copy
   ? svn move
      svn mkdir
      svn list
      svn help
3. Examine your changes.
   ? svn status
   ? svn diff
4. Possibly undo some changes.
   ? svn revert
5. Resolve conflicts (merge others' changes).
   ? svn update
   ? svn resolve
6. Commit your changes.
   ? svn commit

$ svn status -v(verbose) | less
因为列表太多,用Less命令分页查看,按q退出Less.

None of the prior invocations to svn status contact the repository—instead, they compare
the metadata in the .svn directory with the working copy. Finally, there is the -
-show-updates (-u) option, which contacts the repository and adds information about
things that are out of date:
$ svn status -u -v
M          *           44            23       sally        README
M                      44            20       harry        bar.c
           *           44            35       harry        stuff/trout.c
D                      44            19       ira          stuff/fish.c
A                       0             ?        ?           stuff/things/bloo.h
Status against revision:              46
Notice the two asterisks: if you were to run svn update at this point, you would receive
changes to README and trout.c. This tells you some very useful information—you'll
need to update and get the server changes on README before you commit, or the reposit-
ory will reject your commit for being out of date (more on this subject later).

svn revert item has exactly the same effect as deleting item from your
working copy and then running svn update -r BASE item. However, if
you're reverting a file, svn revert has one very noticeable difference—it
doesn't have to communicate with the repository to restore your file.
Resolve Conflicts (Merging Others' Changes)
     We've already seen how svn status -u can predict conflicts. Suppose you run svn
     update and some interesting things occur:
     $ svn update
     U INSTALL
     G README
     Conflict discovered in 'bar.c'.
     Select: (p) postpone, (df) diff-full, (e) edit,
                (h) help for more options:
     The U and G codes are no cause for concern; those files cleanly absorbed changes from
     the repository. The files marked with U contained no local changes but were Updated with
     changes from the repository. The G stands for merGed, which means that the file had local
     changes to begin with, but the changes coming from the repository didn't overlap with the local changes.

                                                                   With a single Subversion
command, you can check out the repository (or restore an existing working copy) exactly
as it was at any date or revision number in the past. However, sometimes you just want to
peer into the past instead of going into it.
Several commands can provide you with historical data from the repository:
svn log
     Shows you broad information: log messages with date and author information attached
     to revisions and which paths changed in each revision
svn diff
     Shows line-level details of a particular change
svn cat
     Retrieves a file as it existed in a particular revision number and displays it on your
     screen
svn list
     Displays the files in a directory for any given revision

svn cat
        If you want to examine an earlier version of a file and not necessarily the differences
        between two files, you can use svn cat:
        $ svn cat -r 2 rules.txt
        Be kind to others
        Freedom = Chocolate Ice Cream
        Everything in moderation
        Chew with your mouth open
        $
        You can also redirect the output directly into a file:
        $ svn cat -r 2 rules.txt > rules.txt.v2
        $
svn list
        The svn list command shows you what files are in a repository directory without actually
        downloading the files to your local machine:
        $ svn list http://svn.collab.net/repos/svn
        README
        branches/
        clients/
        tags/
        trunk/
        If you want a more detailed listing, pass the --verbose (-v) flag to get output like this:
Fetching Older Repository Snapshots
     In addition to all of the previous commands, you can use svn update and svn checkout
     with the --revision option to take an entire working copy “back in time”:
$ svn checkout -r 1729 # Checks out a new working copy at r1729
...
$ svn update -r 1729 # Updates an existing working copy to r1729
...
Lastly, if you're building a release and wish to bundle up your files from Subversion but
don't want those pesky .svn directories in the way, you can use svn export to create a
local copy of all or part of your repository sans .svn directories. As with svn update and
svn checkout, you can also pass the --revision option to svn export:
$ svn export http://svn.example.com/svn/repos1 # Exports latest revision
...
$ svn export http://svn.example.com/svn/repos1 -r 1729
# Exports revision r1729
However, if you're definitely not going to use a working copy again, you can safely delete
the entire thing, but you'd be well served to take a look through the working copy for unver-
sioned files. To find these files, run svn status and review any files that are prefixed with
a ? to make certain that they're not of importance. After you're done reviewing, you can
safely delete your working copy.

                          svn cleanup does: it searches your working copy and runs any
leftover logs, removing working copy locks in the process. If Subversion ever tells you that
some part of your working copy is “locked,” this is the command that you should run. Also,
svn status will display an L next to locked items:
$ svn status
    L      somedir
M          somedir/foo.c
$ svn cleanup
$ svn status
M          somedir/foo.c



雖然一開始安裝的是 Ubuntu Desktop 版本(目前最新是 7.10 版),但是在 Ubuntu 下安裝伺服器套件是非常簡單的一件事,只要確定你的電腦可以連上網路,確認你的 source.list 是否正確?(建議您安裝 Lazybuntu 懶人包),按下面步驟即可完成安裝:
(參考文件:在 Ubuntu 中使用 Apache2 管理 Subversion 版本控制系統)
底下以文字介面的安裝為主,若您使用 GUI 介面的 Synaptic 套件管理程式也可以。
1. 安裝 Apache2 和 Subversion 模組:
$sudo apt-get install apache2 apache2-common apache2-utils apache2-doc libapache-svn subversion
你也可以選擇安裝 subcommander(Ubuntu 底下的 SVN GUI Client)。
2. 建立 Subversion 儲存庫(Repository)
a. 建立 SVN Root 目錄:
$sudo mkdir -p /var/local/svnroot
b. 初始化儲存庫:
$sudo svnadmin create /var/local/svnroot
c. 授予 Apache(www-data) 使用者存取的權限:
$sudo chown -R www-data:www-data /var/local/svnroot
3. 修改 Apache2 的設定:
$sudo gedit /etc/apache2/mods-available/dav_svn.conf
修改 "Location" 區段,內容對應如下:
<Location>
DAV svn
SVNPath /var/local/svnroot
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>


Location 後面所接的是在 URL 所要打的網址,以本例而言,透過瀏覽器要輸入:http://localhost/svnroot
SVNPath 為 Subversion 的檔案庫路徑,如果將 SVNPath 改為 SVNParentPath,則泛指在 SVNParentPath 下的所有目錄都會被視為是 Subversion 檔案庫。
AuthUserFile 則是指存放使用者名稱及密碼的檔案路徑。
4. 創建使用者驗証資訊:
$sudo htpasswd2 [-c] /etc/subversion/passwd username
依照指示輸入使用者密碼即可完成驗証。
-c:表示是否要新建檔案,舊有檔案內容會完全刪除,適用於第一次建立 passwd 檔時。

5. 重新啟動 Apache2:
$sudo /etc/init.d/apache2 restart
6. 打開瀏覽器,訪問http://localhost/svnroot, 就可以看到Subversion庫的網頁。(當然,現在還沒有任何東東,下面我們要導入一些文件)
7. 匯入(inmport) /home/username/workspace中的文件到http://localhost/svnroot 下的workspace目錄(原始專案目錄);"操作注釋"的內容可隨需求添加,username 為專案使用者名稱。
$ svn import -m "操作注釋" /home/username/workspace http://localhost/svnroot/workspace
8. 取出(checkout)剛才匯入的專案:
checkout http://localhost/svnroot/workspace 中的文件到/home/username/test
$svn checkout http://localhost/svnroot/workspace /home/username/test
注意:匯出的目錄名稱不可與匯入的目錄名稱相同(最好是將原始的專案目錄(workspace)與匯出的工作目錄(sandbox)區分開來)。
8. 若您需要 Windows 下的 GUI 介面工具,可以下載安裝 TortoiseSVN 工具。(請一併下載並安裝語言套件Language Pack)
安裝完成後請依下步驟設定語言介面:

a. 開啟 TortoiseSVN 設定頁面(在入一資料夾上按滑鼠右鍵):
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 19:31 , Processed in 0.284403 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表