svn命令 通常都有帮助,可通过如下方式查询:
transaction$ svn help
知道了子命令,但是不知道子命令的用法,还可以查询:
$ svn help add
开发人员常用命令
(1) 导入项目
$ cd ~/project
$ mkdir -p svntest/{trunk,branches,tags}
$ svn import svntest localhost/test/svntest --message "Start project"
...
$ rm -rf svntest
我们新建一个项目svntest,在该项目下新建三个子目录:trunk,开发主干;branches,开发
分支;tags,开发阶段性标签。然后导入到版本库test下,然后把svntest拿掉。
(2) 导出项目
$ svn checkout localhost/test/svntest/trunk
修订版本号的指定方式是每个开发人员必须了解的,以下是几个参考例子,说明可参考svn推荐书。
$ svn diff --revision PREV:COMMITTED foo.c
# shows the last change committed to foo.c
$ svn log --revision HEAD
庐舍# shows log message for the latest repository commit
$ svn diff --revision HEAD
# compares your working file (with local changes) to the latest version
# in the repository
$ svn diff --revision BASE:HEAD foo.c
# compares your “pristine” foo.c (no local changes) with the
# latest version in the repository
$ svn log --revision BASE:HEAD
# shows all commit logs since you last updated
google code jam
$ svn update --revision PREV foo.c
# rewinds the last change on foo.c
# (foo.c's working revision is decread)
$ svn checkout --revision 3
# specified with revision number
$ svn checkout --revision {2002-02-17}
knock$ svn checkout --revision {15:30}
$ svn checkout --revision {15:30:00.200000}
$ svn checkout --revision {"2002-02-17 15:30"}
$ svn checkout --revision {"2002-02-17 15:30 +0230"}
$ svn checkout --revision {2002-02-17T15:30}
$ svn checkout --revision {2002-02-17T15:30Z}
$ svn checkout --revision {2002-02-17T15:30-04:00}
$ svn checkout --revision {20020217T1530}
$ svn checkout --revision {20020217T1530Z}
$ svn checkout --revision {20020217T1530-0500}
(3) 日常指令
$ svn update
慢慢地英文
$ svn add foo.file
$ svn add foo1.dir
$ svn add foo2.dir --non-recursive
$ svn delete README
$ svn copy foo bar
$ svn move foo1 bar1
$ svn status
$ svn status --verbo
$ svn status --verbo --show-updates
$ svn status stuff/fox.c
$ svn diff
$ svn diff > patchfile
$ svn revert README
$ svn revert
修改冲突发生时,会生成三个文件:.mine, .rOLDREV, .rNEWREV。比如:
$ ls -l
ine
1
2
解决修改冲突方式之一:修改冲突的文件,然后运行命令:
$ svn
方式之二:用库里的新版本覆盖你的修改:
$
cfs$ svn
方式之三:撤销你的修改,这种方式不需要运行resolved子命令:
$ svn
Reverted ''
$ ls sandwich.*
确保没问题后,就可以提交了。
$ svn commit --message "Correct some fatal problems"
$ svn commit --file logmsg
$ svn commit
(4) 检验版本历史
$ svn log
$ svn log --revision 5:19
$ svn log foo.c
$ svn log -r 8 -v
$ svn diff
$ svn diff --revision
$ svn diff --revision 2:
$ svn diff --revision 4:5 /repos/example/trunk/
$ svn cat --revision
$ svn cat --revision > v2
$ svn list /repos/svn
$ svn list --verbo /repos/svn
$ svn checkout --revision 1729 # Checks out a new working copy at r1729
…
$ svn update --revision 1729 # Updates an existing working copy to r1729
戴尔英语…
(5) 其他有用的命令
flamingosvn cleanup
为失败的事务清场。
(6) 分支和合并
choo a urname什么意思建立分支方法一:先checkout然后做拷贝,最后提交拷贝。
$ svn checkout /repos/calc bigwc
A bigwc/trunk/
A bigwc/trunk/Makefile
A bigwc/trunk/integer.c
A bigwc/trunk/button.c
A bigwc/branches/
Checked out revision 340.
$ cd bigwc
$ svn copy trunk branches/my-calc-branch
$ svn status
A + branches/my-calc-branch
$ svn commit -m "Creating a private branch of /calc/trunk."
Adding branches/my-calc-branch
broadcastingCommitted revision 341.
建立分支方法二:直接远程拷贝。
$ svn copy /repos/calc/trunk \
/repos/calc/branches/my-calc-branch \
-m "Creating a private branch of /calc/trunk."
Committed revision 341.
建立分支后,你可以把分支checkout并继续你的开发。
$ svn checkout /repos/calc/branches/my-calc-branch
假设你已经checkout了主干,现在想切换到某个分支开发,可做如下的操作: