我想提交一个不同的审查,为一个开源项目。

我得到的代码使用SVN(从终端,Ubuntu)。我对一些文件做了小修改。现在我只想提交一个更改。我所做的其余更改是用于调试的,不再需要。

我已经使用svn di > ~/os/firstdiff.diff生成了diff

所以我的问题是,如何丢弃局部更改?

是否有SVN的方法来做到这一点?如果没有,我将不得不去每个文件,并删除我所有的编辑。 然后我会生成一个新的diff,并提交它。


当前回答

您可以对要放置的文件使用commit命令,并使用svn revert命令丢弃剩余的本地更改

其他回答

需要使用svn revert命令恢复所有修改。

将更改恢复到文件:svn Revert foo.c 恢复文件的整个目录:svn Revert——recursive。

你可以用

 svn diff important/file1.c important/file2.c > $HOME/os/firstdiff.diff

在发表你的不同意见时,别忘了告诉你所反对的修订意见。

正如其他人回答的那样,您也可以小心地使用svn revert。这取决于你是否想为将来的工作保留你的本地更改。

转到该存储库的根目录并运行以下命令

svn revert --depth=infinity .

只需使用svn revert命令,例如:

svn revert some_file.php

它(和其他svn命令一样)在svnbook资源或手册页,甚至svn help命令中都有很好的文档。

我知道这是一个老问题,但是……这现在可以很容易地完成:

svn revert -R --remove-added /path/to/dir && svn cleanup --remove-unversioned /path/to/dir

第一部分递归地恢复更改,并删除已添加但未提交的文件。

第二部分删除路径中所有未版本化或被忽略的项。

以上信息的最佳来源。就是svn客户端本身

❯ svn help revert
revert: Restore pristine working copy state (undo local changes).
usage: revert PATH...

  Revert changes in the working copy at or within PATH, and remove
  conflict markers as well, if any.

  This subcommand does not revert already committed changes.
  For information about undoing already committed changes, search
  the output of 'svn help merge' for 'undo'.

Valid options:
  --targets ARG            : pass contents of file ARG as additional args
  -R [--recursive]         : descend recursively, same as --depth=infinity
  --depth ARG              : limit operation by depth ARG ('empty', 'files',
                             'immediates', or 'infinity')
  -q [--quiet]             : print nothing, or only summary information
  --changelist [--cl] ARG  : operate only on members of changelist ARG
  --remove-added           : reverting an added item will remove it from disk

❯ svn help cleanup
cleanup: Either recover from an interrupted operation that left the working copy locked,
or remove unwanted files.
usage: 1. cleanup [WCPATH...]
       2. cleanup --remove-unversioned [WCPATH...]
          cleanup --remove-ignored [WCPATH...]
       3. cleanup --vacuum-pristines [WCPATH...]

  1. When none of the options --remove-unversioned, --remove-ignored, and
    --vacuum-pristines is specified, remove all write locks (shown as 'L' by
    the 'svn status' command) from the working copy.  Usually, this is only
    necessary if a Subversion client has crashed while using the working copy,
    leaving it in an unusable state.

    WARNING: There is no mechanism that will protect write locks still
             being used by other Subversion clients. Running this command
             without any options while another client is using the working
             copy can corrupt the working copy beyond repair!

  2. If the --remove-unversioned option or the --remove-ignored option
    is given, remove any unversioned or ignored items within WCPATH.
    Note that the 'svn status' command shows unversioned items as '?',
    and ignored items as 'I' if the --no-ignore option is given to it.

  3. If the --vacuum-pristines option is given, remove pristine copies of
    files which are stored inside the .svn directory and which are no longer
    referenced by any file in the working copy.