svn的使用技巧 svn 技巧

1、Subversion 版本库的 URL
$ svn checkout http://svn.example.com:9834/repos$ svn checkout file:///var/svn/repos$ svn checkout file://localhost/var/svn/repos
在Windows平台下使用file://模式C:> svn checkout file:///X:/var/svn/reposC:> svn checkout "file:///X|/var/svn/repos"

表 1.1. 版本库访问 URL模式访问方法file:/// 直接版本库访问(本地磁盘)http:// 通过配置Subversion的Apache服务器的WebDAV协议https:// 与http://相似,但是包括SSL加密。svn:// 通过svnserve服务自定义的协议svn+ssh:// 与svn://相似,但通过SSH封装。

1.1、检出$ svn checkout http://svn.example.com/repos/calcA calc/MakefileA calc/integer.cA calc/button.cChecked out revision 56.$ ls -A calcMakefile button.c integer.c .svn/
1.2、提交修改$ svn commit button.c -m "Fixed a typo in button.c."Sending button.cTransmitting file data .Committed revision 57.
1.3、更新$ svn updateU button.cUpdated to revision 57.





svn的使用技巧 svn 技巧
2、导入数据到版本库
$ svnadmin create /var/svn/newrepos$ svn import mytree file:///var/svn/newrepos/some/project-m "Initial import"Adding mytree/foo.cAdding mytree/bar.cAdding mytree/subdirAdding mytree/subdir/quux.hCommitted revision 1.
$ svnadmin create /var/svn/newrepos$ svn import mytree file:///var/svn/newrepos/some/project-m "Initial import"Adding mytree/foo.cAdding mytree/bar.cAdding mytree/subdirAdding mytree/subdir/quux.hCommitted revision 1.在上一个例子里,将会拷贝目录mytree到版本库的some/project下:

2.1、查看svn版本库文件$ svn list file:///var/svn/newrepos/some/projectbar.cfoo.csubdir/

2.2、 推荐的版本库布局$ svn list file:///var/svn/repos/trunk/branches/tags

2.3、 初始化检出$ svn checkout http://svn.collab.net/repos/svn/trunkA trunk/Makefile.inA trunk/ac-helpersA trunk/ac-helpers/install.shA trunk/ac-helpers/install-shA trunk/build.conf…Checked out revision 8810.


因为你可以使用版本库的URL作为唯一参数取出一个工作拷贝,你也可以在版本库URL之后指定一个目录,这样会将你的工作目录放到你的新目录,举个例子:$ svn checkout http://svn.collab.net/repos/svn/trunksubvA subv/Makefile.inA subv/ac-helpersA subv/ac-helpers/install.shA subv/ac-helpers/install-shA subv/build.conf…Checked out revision 8810.这样将把你的工作拷贝放到subv而不是和前面那样放到trunk,如果subv不存在,将会自动创建


1. 更新你的工作拷贝。svn update
2. 做出修改svn addsvn deletesvn copysvn move
3. 检验修改svn statussvn diff
4. 可能会取消一些修改svn revert
5. 解决冲突(合并别人的修改)svn updatesvn resolved
6. 提交你的修改svn commit

2.4.1. 更新你的工作副本$ svn updateU foo.cU bar.cUpdated to revision 2.

2.4.2. 修改你的工作副本
svn add foo预定将文件、目录或者符号链foo添加到版本库,当你下次提交后,foo会成为其父目录的一个子对象。注意,如果foo是目录,所有foo中的内容也会预定添加进去,如果你只想添加foo本身,请使用--non-recursive (-N)参数。
svn delete foo预定将文件、目录或者符号链foo从版本库中删除,如果foo是文件,它马上从工作拷贝中删除,如果是目录,不会被删除,但是Subversion准备好删除了,当你提交你的修改,foo就会在你的工作拷贝和版本库中被删除。2
svn copy foo barCreate a new item bar as a duplicate of foo and automaticallyschedule bar for addition.When bar is added to the repository on the next commit, itscopy history is recorded (as havingoriginally come from foo). svn copy does not createintermediate directories unless you pass the--parents option.
svn move foo barThis command is exactly the same as running svn copy foo bar;svn delete foo.That is, bar is scheduled for addition as a copy of foo, andfoo is scheduled for removal. svnmove does not create intermediate directories unless you passthe --parents option.svn mkdir blortThis command is exactly the same as running mkdir blort; svnadd blort. That is, anew directory named blort is created and scheduled foraddition.

拷贝工作拷贝的一个项目(只是预定要拷贝—在提交之前不会影响版本库):
$ svn copy foo.txt bar.txtA bar.txt$ svn statusA + bar.txtCopy several files in a working copy into asubdirectory:
$ svn cp bat.c baz.c qux.c srcA src/bat.cA src/baz.cA src/qux.cCopy revision 8 of bat.c into your working copy under adifferent name:
$ svn cp bat.c ya-old-bat.cA ya-old-bat.c拷贝你的工作拷贝的一个项目到版本库的URL(直接的提交,所以需要提供一个提交信息):
$ svn copy near.txt file:///var/svn/repos/test/far-away.txt -m"Remote copy."
Committed revision 8.拷贝版本库的一个项目到你的工作拷贝(只是预定要拷贝—在提交之前不会影响版本库):
$ svn copy file:///var/svn/repos/test/far-away near-hereA near-here这是恢复死掉文件的推荐方式!
And finally, copy between two URLs:
$ svn copy file:///var/svn/repos/test/far-awayfile:///var/svn/repos/test/over-there -m "remote copy."
Committed revision 9.$ svn copy file:///var/svn/repos/test/trunk file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tagtree"
Committed revision 12.



查看svn版本库好状态$ svn status stuff/fish.csvn status也有一个--verbose(-v)选项,它可以显示工作拷贝中的所有项目,即使没有改变过的:$ svn status -v
最后,是--show-updates(-u)选项,它将会联系版本库为已经过时的数据添加新信息:$ svn status -u -v


检查你的本地修改的详情$ svn diffIndex: bar.c

$ svn diff > patchfile


取消本地修改$ svn revert READMEReverted 'README'
Subversion把文件恢复到未修改的状态,叫做.svn目录的“原始”拷贝,应该知道svnrevert可以恢复任何预定要做的操作,举个例子,你不再想添加一个文件:$ svn status foo? foo$ svn add fooA foo$ svn revert fooReverted 'foo'$ svn status foo? foo
解决冲突(合并别人的修改)$ svn updateU INSTALLG READMEConflict discovered in 'bar.c'.Select: (p) postpone, (df) diff-full, (e) edit,(h) help for more options:

在我们详细查看每个选项含义之前,让我们简短的回顾一下所有这些选项。(p)ostpone让文件在更新完成之后保持冲突状态。(d)iff使用标准区别格式显示base修订版本和冲突文件本身的区别。(e)dit用你喜欢的编辑器打开冲突的文件,编辑器是环境变量EDITOR设置的。(r)esolved完成文件编辑之后,通知svn你已经解决了文件的冲突,它必须接受当前的内容—从本质上讲就是你已经“解决了”冲突。(m)ine-(f)ull丢弃新从服务器接收的变更,并只使用你查看文件的本地修改。(t)heirs-(f)ull丢弃你对查看文件的本地修改,只使用从服务器新接收的变更。(l)aunch启动一个外置程序来执行冲突解决,这需要一些预先的准备。(h)elp显示所有在冲突解决时可能使用的命令。我们现在会更详细的覆盖这些命令,根据关联功能对其进行分组。

如果你延办一个冲突,你需要在Subversion允许你提交你的修改之前解决冲突,你可以通过svn resolve命令和--accept选项的多个参数的一个完成。如果你希望选择上次检出后修改之前的文件版本,选择base参数。如果你希望选择只包含你修改的版本,选择mine-full参数。
如果你希望选择最近从服务器更新的版本(因此会丢弃你的所以编辑),选择theirs-full参数。$ svn resolve --accept working sandwich.txtResolved conflicted state of 'sandwich.txt'

丢弃你的修改而接收新获取的修订版本$ svn update

Punting: Using svn revert$ svn revert sandwich.txtReverted 'sandwich.txt'$ ls sandwich


提交你的修改$ svn commit -m "Corrected number of cheese slices."Sending sandwich.txtTransmitting file data .Committed revision 3.





检验历史svn log
svn diffShows line-level details of a particular changesvn catRetrieves a file as it existed in a particular revision numberand displays it on your screensvn listDisplays the files in a directory for any given revision

注意日志信息缺省根据时间逆序排列,如果希望察看特定顺序的一段修订版本或者单一版本,使用--revision (-r)选项:$ svn log -r 5:19 # shows logs 5 through 19 in chronologicalorder$ svn log -r 19:5 # shows logs 5 through 19 in reverseorder$ svn log -r 8 # shows log for revision 8

你也可以检查单个文件或目录的日志历史,举个例子:$ svn log foo.c$ svn log http://foo.com/svn/trunk/code/foo.c

如果你希望得到目录和文件更多的信息,你可以对svn log命令使用--verbose (-v)开关,因为Subversion允许移动和复制文件和目录,所以跟踪路径修改非常重要,在详细模式下,svn log 输出中会包括一个路径修改的历史:
svn log也有一个--quiet (-q)选项,会禁止日志信息的主要部分,当与--verbose结合使用,仅会显示修改的文件名。



检查历史修改详情svn diff有三种不同的用法检查本地修改$ svn diffIndex: rules.txt
比较工作副本和版本库If a single --revision (-r) number is passed, your workingcopy is compared to the specifiedrevision in the repository:
$ svn diff -r 3 rules.txt

Comparing repository revisions
$ svn diff -r 2:3 rules.txtIndex: rules.txt

A more convenient way of comparing one revision to theprevious revision is to use the --change(-c) option:$ svn diff -c 3 rules.txt
浏览版本库通过svn cat和svn list,你可以在未修改工作修订版本的情况下查看文件和目录的内容,实际上,你甚至也不需要有一个工作拷贝。
如果你只是希望检查一个过去的版本而不希望察看它们的区别,使用svn cat
svn list可以在不下载文件到本地目录的情况下来察看目录中的文件如果你希望察看详细信息,你可以使用--verbose(-v) 参数

获得旧的版本库快照除了以上的命令,你可以使用带参数--revision的svn update和svn checkout来使整个工作拷贝“回到过去”$ svn checkout -r 1729 # Checks out a new working copy atr1729$ svn update -r 1729 # Updates an existing working copy tor1729
许多Subversion新手使用前面的svn update实例来“回退”修改,但是你不能提交修改,你获得有新修订版本的过时工作拷贝也是没有用的。关于如何“回退”,我们可以看第 4.3.5 节 “找回删除的项目”。

处理你的工作副本一个svn update命令可以让使用的文件成为最新
从中断中恢复$ svn statusL somedirM somedir/foo.c$ svn cleanup$ svn statusM somedir/foo.c

修订版本关键字HEAD版本库中最新的(或者是“最年轻的”)版本。BASE工作拷贝中一个条目的修订版本号,如果这个版本在本地修改了,则这里指的是这个条目在本地未修改的版本。
COMMITTED项目最近修改的修订版本,与BASE相同或更早。PREV
The revision immediately before the last revision in which anitem changed. Technically, this boilsdown to

因为可以从描述中得到,关键字PREV,BASE和COMMITTED只在引用工作拷贝路径时使用,而不能用于版本库URL,而关键字HEAD则可以用于两种路径类型。
$ svn diff -r PREV:COMMITTED foo.c# shows the last change committed to foo.c$ svn log -r HEAD# shows log message for the latest repository commit$ svn diff -r HEAD# compares your working copy (with all of its local changes)to the# latest version of that tree in the repository$ svn diff -r BASE:HEAD foo.c# compares the unmodified version of foo.c with the latestversion of# foo.c in the repository$ svn log -r BASE:HEAD# shows all commit logs for the current versioned directorysince you# last updated$ svn update -r PREV foo.c# rewinds the last change on foo.c, decreasing foo.c's workingrevision$ svn diff -r BASE:14 foo.c# compares the unmodified version of foo.c with the way foo.clooked# in revision 14

版本日期在版本控制系统以外,修订版本号码是没有意义的,但是有时候你需要将时间和历史修订版本号关联。为此,--revision(-r)选项接受使用花括号({和})包裹的日期输入,Subversion支持标准ISO-8601日期和时间格式,也支持一些其他的。下面是一些例子。(记住使用引号括起所有包含空格的日期。)
$ svn checkout -r {2006-02-17}$ svn checkout -r {15:30}$ svn checkout -r {15:30:00.200000}svn checkout -r {"2006-02-17 15:30"}$ svn checkout -r {"2006-02-17 15:30 +0230"}$ svn checkout -r {2006-02-17T15:30}$ svn checkout -r {2006-02-17T15:30Z}$ svn checkout -r {2006-02-17T15:30-04:00}$ svn checkout -r {20060217T1530}$ svn checkout -r {20060217T1530Z}$ svn checkout -r {20060217T1530-0500}

当你指定一个日期,Subversion会在版本库找到接近这个日期的最近版本,并且对这个版本继续操作:$ svn log -r {2006-11-28}------------------------------------------------------------------------r12 | ira | 2006-11-27 12:31:51 -0600 (Mon, 27 Nov 2006) | 6lines



你可以使用时间段,Subversion会找到这段时间的所有版本:$ svn log -r {2006-11-20}:{2006-11-29}

创建锁定$ svn lock banana.jpg -m "Editing file for tomorrow'srelease."'banana.jpg' locked by user 'harry'.

通过svn status和svn info的输出我们可以看到文件已经锁定。


$ svn unlock banana.c'banana.c' unlocked.


发现锁定When a commit fails due to someone else's locks, it's fairlyeasy to learn about them. The easiest wayis to run svn status --show-updates:
$ svn status -uM 23 bar.cM O 32 raisin.jpg* 72 foo.hStatus against revision: 105


解除和偷窃锁定从管理员的位子上很容易打破锁定,svnlook和svnadmin程序都有能力从版本库直接显示和删除锁定
$ svnadmin lslocks /var/svn/reposPath: /project2/images/banana.jpgUUID Token:opaquelocktoken:c32b4d88-e8fb-2310-abb3-153ff1236923Owner: frankCreated: 2006-06-15 13:29:18 -0500 (Thu, 15 Jun 2006)Expires:Comment (1 line):Still improving the yellow color.Path: /project/raisin.jpgUUID Token:opaquelocktoken:fc2b4dee-98f9-0310-abf3-653ff3226e6bOwner: harryCreated: 2006-02-16 13:29:18 -0500 (Thu, 16 Feb 2006)Comment (1 line):Need to make a quick tweak to this image.$ svnadmin rmlocks /var/svn/repos /project/raisin.jpgRemoved lock on '/project/raisin.jpg'.

$ svn status -uM 23 bar.cM O 32 raisin.jpg* 72 foo.hStatus against revision: 105$ svn unlock raisin.jpgsvn: 'raisin.jpg' is not locked in this working copy$ svn info raisin.jpg | grep URLURL: http://svn.example.com/repos/project/raisin.jpg$ svn unlockhttp://svn.example.com/repos/project/raisin.jpgsvn: Unlock request failed: 403 Forbidden(http://svn.example.com)$ svn unlock --forcehttp://svn.example.com/repos/project/raisin.jpg'raisin.jpg' unlocked.



外部定义用svn:externals属性来定义外部定义,你可以用svn propset或svn propedit(见第 3.2.2节“操作属性”)创建和修改这个属性。它可以设置到任何版本化的路经,它的值是一个多行的


$ svn propget svn:externals calcthird-party/sounds http://svn.example.com/repos/soundsthird-party/skins -r148 http://svn.example.com/skinprojthird-party/skins/toolkit -r21http://svn.example.com/skin-maker注意前一个外部定义实例,当有人取出了一个calc目录的工作拷贝,Subversion会继续来取出外部定义的项目。$ svn checkout http://svn.example.com/repos/calcA calcA calc/MakefileA calc/integer.cA calc/button.cChecked out revision 148.Fetching external item into calc/third-party/soundsA calc/third-party/sounds/ding.oggA calc/third-party/sounds/dong.oggA calc/third-party/sounds/clang.ogg…A calc/third-party/sounds/bang.oggA calc/third-party/sounds/twang.oggChecked out revision 14.Fetching external item into calc/third-party/skins

$ svn propget svn:externals calchttp://svn.example.com/repos/sounds third-party/sounds-r148 http://svn.example.com/skinproj third-party/skins-r21 http://svn.example.com/skin-makerthird-party/skins/toolkitOr, making use of the peg revision syntax (which we describein detail in 第 3.9 节 “Peg 和实施修订版本”), it might appear as:$ svn propget svn:externals calchttp://svn.example.com/repos/sounds third-party/soundshttp://svn.example.com/skinproj@148 third-party/skinshttp://svn.example.com/skin-maker@21third-party/skins/toolkit


$ svn checkout http://svn.example.com/projects .A my-projectA my-project/some-dirA my-project/external-dir…Fetching external item into 'my-project/some-dir/subdir'Checked out external at revision 11.Checked out revision 11.$ svn propget svn:externals my-project/some-dirsubdirhttp://svn.example.com/projects/my-project/external-dir$现在你使用svn move将目录my-project改名,此刻,你的外部定义还是指向myproject目录,即使这个目录已经不存在了。$ svn move -q my-project renamed-project$ svn commit -m "Rename my-project to renamed-project."Deleting my-projectAdding renamed-projectCommitted revision 12.$ svn updateFetching external item into'renamed-project/some-dir/subdir'svn: Target path does not exi



$ svn propget svn:externals calc^/sounds third-party/sounds/skinproj@148 third-party/skins//svn.example.com/skin-maker@21third-party/skins/toolkit

  

爱华网本文地址 » http://www.413yy.cn/a/25101013/162778.html

更多阅读

win8使用技巧 精 win8.1的使用技巧

win8使用技巧 精——简介 Win 8早已经问世了,专业版已经推出,笔者率先尝试了一下,感觉非常不错,操作体验很流畅,如果是平板的话,哪会爽到家的,台式机也很不错,喜欢捣鼓的朋友安装后未免有些不习惯,下面就介绍一些Win8使用的小技巧来告诉大家,

声卡驱动的安装和调试以及使用技巧 创新声卡调试技巧

声卡驱动的安装和调试以及使用技巧——简介电脑使用的过程中声卡是一个很关键的因素,我们欣赏电影、听音乐、包括玩游戏,声音的品质好坏都是声卡决定的,我们要学会调试声卡和安装声卡,同时也要掌握声卡的使用技巧,这样我们才可以听到高品

笔记本电脑触摸板使用技巧 笔记本电脑鼠标如何用

笔记本电脑触摸板使用技巧——简介国内笔记本电脑内置的触控板使用方法有很多还没有发挥出来,这对新手来说是有必要学一学的,最好不要依赖外置鼠标(就是现代主流的有线鼠标和无线鼠标)。由于外形鼠标随身带很不方便,因此使用笔记本电脑

尼康d90使用技巧和摄影技巧 尼康d90按键功能讲解

尼康d90使用技巧和摄影技巧——简介 尼康d90的功能和性能比较强大,要熟练运用,首先要掌握使用技巧和摄影技巧。尼康d90使用技巧和摄影技巧——尼康d90主要的使用技巧:尼康d90使用技巧和摄影技巧 1、 1、使用实时取景 开启实时取景功

办公软件Word使用技巧 办公软件的使用技巧

办公软件Word使用技巧欢迎你光临NQJ0108的图书馆·四则技巧处理Word表格更快更轻松23/11/2010·活学善用分享经典Word2010小技巧23/11/2010·用OfficeWord制作公章的简单方法23/11/2010·Word2007中快速完成大量表格数据汇总23/11/2

声明:《svn的使用技巧 svn 技巧》为网友素好女孩分享!如侵犯到您的合法权益请联系我们删除