Download
svn by david zhang n.
Skip this Video
Loading SlideShow in 5 Seconds..
SVN by David Zhang PowerPoint Presentation
Download Presentation
SVN by David Zhang

SVN by David Zhang

228 Vues Download Presentation
Télécharger la présentation

SVN by David Zhang

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. SVN by David Zhang

  2. 内容 Svn基本操作 Svn分支和合并 TracLink的使用

  3. svn --help 用法: svn <subcommand> [options] [args] svn help <subcommand> 帮助

  4. 导入数据到版本库 svn import 是将未版本化文件导入版本库的最快方法,会根据需要创建中介目录。 $ svnadmin create /usr/local/svn/newrepos $ svn import mytree file:///usr/local/svn/newrepos/some/project \ -m "Initial import" Adding mytree/foo.c Adding mytree/bar.c Adding mytree/subdir Adding mytree/subdir/quux.h Committed revision 1.

  5. 初始化检出 使用Subversion,从checkout开始 本地拷贝 HEAD版本 $ svn checkout http://svn.collab.net/repos/svn/trunk A trunk/Makefile.in A trunk/ac-helpers A trunk/ac-helpers/install.sh A trunk/ac-helpers/install-sh A trunk/build.conf ... Checked out revision 8810.

  6. 基本的工作循环 • 可能会取消一些修改 svn revert • 解决冲突(合并别人的修改) svn update svn resolved • 提交你的修改 svn commit • • 更新你的工作拷贝 • svn update • • 做出修改 • svn add • svn delete • svn copy • svn move • • 检验修改 • svn status • svn diff

  7. 更新你的工作副本 $ svn update U foo.c U bar.c Updated to revision 2.

  8. 修改你的工作副本 svn add foo svn delete foo svn copy foo bar svn move foo bar svn mkdir blort

  9. 检查你的修改 查看你的修改概况 $svn status A stuff/loot/bloo.h # file is scheduled for addition C stuff/loot/lump.c # file has textual conflicts from an update D stuff/fish.c # file is scheduled for deletion M bar.c # the content in bar.c has local modifications

  10. 检查你的本地修改的详情 $ svn diff $ svn diff > patchfile $ svn diff -- diff-cmd /usr/bin/diff \ --extensions '-bc' foo.c

  11. 取消本地修改 $ svn status README README $ svn delete README D README $ svn revert README Reverted 'README' $ svn status README README $ svn revert README Reverted 'README' • $ svn status foo • ? foo • $ svn add foo • A foo • $ svn revert foo • Reverted 'foo' • $ svn status foo • ? foo

  12. 解决冲突(合并别人的修改) $ svn update U INSTALL #U表明本地没有修改 G README #G表示合并 C bar.c #C表示冲突 Updated to revision 46. 如果你遇到冲突,三件事你可以选择: • “手动”合并冲突文本(检查和修改文件中的冲突标志)。 • 用某一个临时文件覆盖你的工作文件。 • 运行svn revert <filename>来放弃所有的本地修改。 $ svn resolved sandwich.txt Resolved conflicted state of 'sandwich.txt'

  13. 手工合并冲突 $ cat sandwich.txt $ svn resolved sandwich.txt $ svn commit -m "Go ahead and use my sandwich, discarding Sally's edits."

  14. 复制文件到你的工作文件 $ svn update C sandwich.txt Updated to revision 2. $ ls sandwich.* sandwich.txt sandwich.txt.mine sandwich.txt.r2 sandwich.txt.r1 $ cp sandwich.txt.r2 sandwich.txt $ svn resolved sandwich.txt

  15. 使用svn revert $ svn revert sandwich.txt Reverted 'sandwich.txt' $ ls sandwich.* sandwich.txt 注意,当你恢复一个冲突的文件时,不需要再运行svn resolved。

  16. 提交你的修改 $ svn commit -m "Corrected number of cheese slices." Sending sandwich.txt Transmitting file data . Committed revision 3. $ svn commit -F logmsg Sending sandwich.txt Transmitting file data . Committed revision 4.

  17. 检验历史 svn log 展示给你主要信息:每个版本附加在版本上的作者与日期 信息和所有路径修改。 svn diff 显示特定修改的行级详细信息。 svn cat 取得在特定版本的某一个文件显示在当前屏幕。 svn list 显示一个目录在某一版本存在的文件。 $ svn log $ svn log -r 5:19 $ svn log -r 19:5 $ svn log -r 8 $ svn log foo.c $ svn log http://foo.com/svn/trunk/code/foo.c

  18. 检查历史修改的详情 svn diff有三种不同的用法: • 检查本地修改$ svn diff • 比较工作拷贝与版本库$ svn diff -r 3 rules.txt • 比较版本库与版本库$ svn diff -r 2:3 rules.txt

  19. 分支与合并

  20. 浏览版本库 $ svn cat -r 2 rules.txt $ svn list -v http://svn.collab.net/repos/svn

  21. TracLinks TracLink 是trac的基本特性之一,实质上是一种在Trac中使用的超连接。 哪里需要使用TracLink: Source code (Subversion) commit messages Wiki pages Full descriptions for tickets, reports and milestones and any other text fields explicitly marked as supporting WikiFormatting.

  22. TracLink使用 一般形式 type:id Some examples: * Tickets: #1 or ticket:1 * Ticket comments: comment:1:ticket:2 * Reports: {1} or report:1 * Changesets: r1, [1], changeset:1 or (restricted) [1/trunk], changeset:1/trunk * Revision log: r1:3, [1:3] or log:@1:3, log:trunk@1:3, [2:5/trunk] * Diffs (requires 0.10): diff:@1:3, diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default or diff:trunk/trac@3538//sandbox/vc-refactoring@3539 * Wiki pages: CamelCase or wiki:CamelCase * Parent page: [..] * Milestones: milestone:1.0 * Attachment: attachment:example.tgz (for current page attachment), attachment:attachment.1073.diff:ticket:944 (absolute path) * Files: source:trunk/COPYING * A specific file revision: source:/trunk/COPYING@200 * A particular line of a specific file revision: source:/trunk/COPYING@200#L25 Display: * Tickets: #1 or ticket:1 * Ticket comments: comment:1:ticket:2 * Reports: {1} or report:1 * Changesets: r1, [1], changeset:1 or (restricted) [1/trunk], changeset:1/trunk * Revision log: r1:3, [1:3] or log:@1:3, log:trunk@1:3, [2:5/trunk] * Diffs (requires 0.10): diff:@1:3, diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default or diff:trunk/trac@3538//sandbox/vc-refactoring@3539 * Wiki pages: CamelCase or wiki:CamelCase * Parent page: .. * Milestones: milestone:1.0 * Attachment: attachment:example.tgz (for current page attachment), attachment:attachment.1073.diff:ticket:944 (absolute path) * Files: source:trunk/COPYING * A specific file revision: source:/trunk/COPYING@200 * A particular line of a specific file revision: source:/trunk/COPYING@200#L25