svn中的revert和update

       转载地址:http://blog.csdn.net/njuitjf/article/details/7546189

       

       svn中的revert和update

今天有人问到revert和update的问题。
刚开始还真被问住了。
因为感觉revert和update都可以将本地的copy更新到以前的一个版本,会有什么不同呢?


查了些资料,并做了个试验,终于发现了它们的不同。


假设当前最新的版本是6,但是,最新的一次提交不是你想要的,也就是想把版本为6的修改干掉
下面来看看如何分辨用revert和update来实现。


1、使用revert
保证本地copy为最新版本,即版本6.
将本地copy revert到版本5.
将本地copy commit。


2、使用update
将本地copy update到版本5.
这个时候是没办法直接提交的,因为你的修改不是在最新的版本(6)上进行的。
需要把版本5做个备份,然后check out版本6.
通过文件比较工具将版本6的本地copy修改为与版本5的本地copy一致。
然后将版本6的本地copy提交。


可见,revert与update的本质区别是,
revert是在本地copy原来版本的基础上进行的修改,若原来本地copy的版本为最新,可以直接commit;
update只是将本地copy更新到一个指定的版本,若更新到的不是最新版本,不能进行commit。


可见revert就是回退修改,但版本保持不变;update是将本地copy更新到一个指定的版本。


看看帮助文档中的说明。


[revert]
revert: Restore pristine working copy file (undo most local edits).
usage: revert PATH...


  Note:  this subcommand does not require network access, and resolves
  any conflicted states.  However, it does not restore removed directories.
  
[update]
update (up): Bring changes from the repository into the working copy.
usage: update [PATH...]


  If no revision is given, bring working copy up-to-date with HEAD rev.
  Else synchronize working copy to revision given by -r.


  For each updated item a line will start with a character reporting the
  action taken.  These characters have the following meaning:


    A  Added
    D  Deleted
    U  Updated
    C  Conflict
    G  Merged
    E  Existed


  A character in the first column signifies an update to the actual file,
  while updates to the file's properties are shown in the second column.
  A 'B' in the third column signifies that the lock for the file has
  been broken or stolen.


  If --force is used, unversioned obstructing paths in the working
  copy do not automatically cause a failure if the update attempts to
  add the same path.  If the obstructing path is the same type (file
  or directory) as the corresponding path in the repository it becomes
  versioned but its contents are left 'as-is' in the working copy.
  This means that an obstructing directory's unversioned children may
  also obstruct and become versioned.  For files, any content differences
  between the obstruction and the repository are treated like a local
  modification to the working copy.  All properties from the repository
  are applied to the obstructing path.  Obstructing paths are reported
  in the first column with code 'E'.


  Use the --set-depth option to set a new working copy depth on the
  targets of this operation.

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值