Useful Commands
Here are some examples of revision keywords in action. Don't worry if the commands don't make sense yet; we'll be explaining these commands as we go through the chapter:
$ 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
$ svn update --revision PREV foo.c # rewinds the last change on foo.c # (foo.c's working revision is decreased)
$ svn info | grep URL
$ svn log -v -r9238 {Path} # to read about the exact changeset which fixed the bug at 9238
$ svn diff -r9237:9238 {path} # to see the patch itself
Undo Changes
- Working Repository
- Undelete a file
- get the path@revision by svn log -v
- svn copy --revision 807 http://svn.example.com/repos/calc/trunk/real.c ./real.c
- svn commit with log message "Resurrected real.c from revision 807, /calc/trunk/real.c."
- or use svn merge to a single file
- Undo a changeset in Repository on Server
Suppose you're working away happily on a working copy of /calc/trunk, and you discover that the change made way back in revision 303, which changed integer.c, is completely wrong. It never should have been committed. You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference:
$ svn merge -r 303:302 http://svn.example.com/repos/calc/trunk U integer.c
$ svn status M integer.c
$ svn diff … # verify that the change is removed …
$ svn commit -m "Undoing change committed in r303." Sending integer.c Transmitting file data . Committed revision 350.
Branch
- Creating a Working Copy of a Branch
- Check Out a branch
- Switch to a branch
- switch command transforms an existing working copy into a different branch
- svn switch command also takes a --revision (-r) option, so you need not always move your working copy to the “tip” of the branch.
- switch command transforms an directory under existing working copy into a different branch
- A superset of svn update
Merge
- Sample Merge Commands
- $ svn merge http://svn.example.com/repos/branch1@150 http://svn.example.com/repos/branch2@212 my-working-copy
- The first syntax lays out all three arguments explicitly, naming each tree in the form URL@REV and naming the working copy target
- $ svn merge -r 100:200 http://svn.example.com/repos/trunk my-working-copy
- second syntax can be used as a shorthand for situations when you're comparing two different revisions of the same URL.
- $ svn merge -r 100:200 http://svn.example.com/repos/trunk
- The last syntax shows how the working-copy argument is optional; if omitted, it defaults to the current directory.
- Merge = Diff and Apply
- Assume that your working copy has no local edits. When you svn update to a particular revision, the changes sent by the server will always apply “cleanly” to your working copy. The server produces the delta by comparing two trees: a virtual snapshot of your working copy, and the revision tree you're interested in. Because the left-hand side of the comparison is exactly equal to what you already have, the delta is guaranteed to correctly convert your working copy into the right-hand tree.
- Undo
- svn revert --recursive
- delete any unversioned files or directories left behind after the revert ( using svn status to check the unversioned the files)
Best Practice
- Tracking Merges Manually
- As there is no way for svn knowing the local changes done by svn merge and local modification by editting, so we need write down the specific revision number (or range of revisions) that are being merged into your branch.
- Previewing Merges
- Check if the last merge happened or not from the svn log information.
- In case the svn merge will mingle the changes to our local modification together so as to no way to revert. Please do one of the below two commands before merging.
- To check the differences in detail, run diff command with the same arguments you would run svn merge This way we can see what will update to our code.
- To get a rough information, run merge with the option --dry-run.
- Noticing or Ignoring Ancestry
- Diff: ignore the ancestor by default. --notice-ancestry
- Merge: sensitive to ancestry by default. --ignore-ancestry
Merging a whole Branch to Trunk
- Get the BASE revision of the branch: svn log --verbose --stop-on-copy {branch_name}
- Go to the trunk cd {application}/trunk
- Get the latest repository revision and refresh local trunk so we can get the HEAD revision: svn update .
- Merge the difference. svn merge -r branch_base:repository_HEAD http://svn.example.com/.../webapps/SampleApps/my-sample-branch
- Check the local status: svn status
- examine the diffs, compile, test, etc...
- Commit the change with the specified the log message: "Merged my-sample-branch changes rBASE:HEAD into the trunk."
- please check http://svnbook.red-bean.com/en/1.0/ch04s04.html#svn-ch-4-sect-4.1 for more details.
Ignore files
- Some files created by an IDE, such as Eclipse are quite annoying. We need to take care of not checking them into svn. Below is my way to ignore those files.
- The files wanna to be ignored
/home/larryli/svn/offline/webapps/TimeTrackerII>svn status .
? .project
? .classpath
? .mymetadata
? .myeclipse
? META-INF/MANIFEST.MF
? WEB-INF/classes
/home/larryli/svn/offline/webapps/TimeTrackerII>ls -ltr
- Edit the file /home/larryli/.subversion>vi /home/larryli/.subversion/config
# global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store .project .classpath .mymetadata .myeclipse MANIFEST.MF classes
- Go back and check. It works ok.
/home/larryli>cd /home/larryli/svn/offline/webapps/TimeTrackerII
/home/larryli/svn/offline/webapps/TimeTrackerII>svn status .
/home/larryli/svn/offline/webapps/TimeTrackerII>
- Online Reference
- http://svnbook.red-bean.com/en/1.1/ch07s02.html
- http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2
分享到:
相关推荐
SVN演示 SVN演示 SVN演示 SVN演示 SVN演示 SVN演示
SVN培训 SVN培训 SVN培训 SVN培训 SVN培训 SVN培训
svn客户端svn客户端svn客户端svn客户端svn客户端
svn插件svn插件
安装svn安装svn安装svn
SVN svn SVN中文手册 SVN资料 svn配置SVN svn SVN中文手册 SVN资料 svn配置SVN svn SVN中文手册 SVN资料 svn配置SVN svn SVN中文手册 SVN资料 svn配置SVN svn SVN中文手册 SVN资料 svn配置SVN svn SVN中文手册 SVN...
centos 7.9服务器 离线 搭建svn服务器 ,该文章适用于 开发人员 实施人员 项目经理用于项目文档管理 代码管理,而不指定如何在centos7.9环境下离线搭建svn服务器,因为大多数的网站只是介绍yum install 的方式,但是...
svn操作手册svn操作手册svn操作手册svn操作手册svn操作手册
是否遇到过公司里的sx向svn提交了不该提交的文件?.sdf debug release 等等,是否对此感到崩溃?!是否svn仓库已经占用了大量的磁盘空间? 使用本图形化工具帮助你将这些文件彻底地从svn中删除。 先导出svn仓库 ...
svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件,svn插件
这是最好的SVN右键清除。中文。不分版本。我下载了好多别人的,没一个能很好的用。有些根本就清 不了,有些要清两次。这个是最好用的,本人测试完全保证没问题。 我们建立SVN时经常遇到新建新的SVN项目后但是里面带...
SVN服务端SVN-Server-3.3.1-x64,SVN客户端TortoiseSVN-1.8.10-x64,SVN插件site-1.10.9,SVN客户端pdf使用说明文档. SVN客户端和eclipse SVN插件这两个版本匹配,可以实现对同一项目同时使用subeclipse和Tortoise ...
找到项目目录,右键--选择“Delete SVN Folders”,即可删除SVN信息并断开项目SVN连接
破解svn密码,用于找回svn密码,直接执行exe文件,就可查看当前打开项目,用到的svn用户名和密码。
下面简单介绍下PLSQL developer工具的SVN版本控制 1, 下载pl/sql-svn插件。 2, 关闭你打开的所有pl/sql窗口。 3,将插件里的SVN_Plugin.dll文件复制到PLSQL DeveloperPlugIns目录下。 4,重新打开pl/sql,...
指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间时间 获取SVN日志指定区间...
清楚svn目录下生成的.svn所有文件夹
svn服务器配置 svn服务器配置 svn服务器配置 svn服务器配置
svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端svn客户端
svn安装工具 svn安装文件 svn安装文件 svn安装文件 svn安装文件