svn使用

svn用于版本管理,跟我们平时开发息息相关。

svn命令对比与普通命令稍微复杂。但是其有强大的help可以帮助我们。

svn help

对于某些功能,仅仅依靠svn help无法完全得到结果。可以通过

svn help your_command

 来进一步查询。

现在有一个问题:1713-目前版本提交了一个重要文件(忘记文件名了),最近我肯定是修改了这个文件,我想看看我修改了什么。

大体思路:

1. 首先根据log查看到底修改了那些文件

2. 找到具体文件使用svn diff来查看修改内容。

 

>>>svn help log
Valid options:
  -r [--revision] arg      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED
  -q [--quiet]             : print as little as possible
  -v [--verbose]           : print extra information
HEAD:版本库中的最新版本。
COMMITED:文件最后提交生成的版本号。
PREV:文件倒数第二次提交生成的版本号。
BASE:目录签出或者签入生成的版本号。

>>>svn log -r 1713:head -v
根据log列表找到自己想要的文件: /zzzadmin/src/ApiBundle/Controller/CenterController.php
这个路径是svn路径,非系统文件路径

>>> svn diff -r 1713:head src/ApiBundle/Controller/CenterController.php # 查看1713和库中最新版本的区别
>>> svn diff -r 1713 src/ApiBundle/Controller/CenterController.php # 查看当前文件和1713区别

 这里只是举个例子,大部分常用操作都可以通过svn help的帮助自己一点点来处理。

下面再讲一下svn properset

  Note: svn recognizes the following special versioned properties
  but will store any arbitrary properties set:
    svn:ignore     - A newline separated list of file patterns to ignore.
    svn:keywords   - Keywords to be expanded.  Valid keywords are:
      URL, HeadURL             - The URL for the head version of the object.
      Author, LastChangedBy    - The last person to modify the file.
      Date, LastChangedDate    - The date/time the object was last modified.
      Rev, Revision,           - The last revision the object changed.
      LastChangedRevision
      Id                       - A compressed summary of the previous
                                   4 keywords.
    svn:executable - If present, make the file executable.
    svn:eol-style  - One of 'native', 'LF', 'CR', 'CRLF'.
    svn:mime-type  - The mimetype of the file.  Used to determine
      whether to merge the file, and how to serve it from Apache.
      A mimetype beginning with 'text/' (or an absent mimetype) is
      treated as text.  Anything else is treated as binary.
    svn:externals  - A newline separated list of module specifiers,
      each of which consists of a relative directory path, optional
      revision flags, and an URL.  For example
        foo             http://example.com/repos/zig
        foo/bar -r 1234 http://example.com/repos/zag
    svn:needs-lock - If present, indicates that the file should be locked
      before it is modified.  Makes the working copy file read-only
      when it is not locked.
  The svn:keywords, svn:executable, svn:eol-style, svn:mime-type and
  svn:needs-lock properties cannot be set on a directory.  A non-recursive
  attempt will fail, and a recursive attempt will set the property
  only on the file children of the directory.

通过 svn help properset 可以看到properset可以修改某些属性。


以设置某个文件夹不纳入版本管理为例:
$ mkdir your_file
$ svn propset svn:ignore your_file . (一定要加.用于代表where to apply the setting.)
$ svn commit -m "ignore your_file"

 

 如何解决 A在svn中add了一个文件;B未更新也Add了一个文件,当B提交时报错:“Failed to add file path/to/file: object of the same name is already scheduled for addition”

Q:  Failed to add file /path/to/directory/with/suspected/duplicate: object of the same name is already scheduled for addition
A:  cd /path/to/directory/with/suspected/duplicate
     svn revert .
     svn cleanup
     svn update

 

 

 

posted @ 2013-08-07 20:24  代码会说话  阅读(476)  评论(0编辑  收藏  举报