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

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

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

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

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


当前回答

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

svn revert some_file.php

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

其他回答

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

丢弃一个特定文件中的本地更改:

$ svn revert example_directory/example_file.txt

丢弃某个特定文件夹中的本地更改:

$ svn revert -R example_directory/

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

svn revert some_file.php

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

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

svn revert --depth=infinity .

简单的svn恢复是足够的原始海报。但是,简单的svn还原在更一般的情况下是不行的

将你想要共享的编辑和不想共享的编辑都放在同一个文件中, 为了自己的个人利益,保留一些你仍然感兴趣的地方变化。

@ErichBSchulz建议使用git add -p是非常合理的,在这种情况下更普遍适用。答案只是缺乏一些细节。假设你的当前目录是你想要创建可共享补丁的目录,你可以这样做:

Checkout pristine version from subversion to a different directory (choose a directory name that does not exist, here using subdirectory TMP/). $ url=$(svn info . | awk '/^URL/ {print $2}') $ svn checkout "$url" TMP Using that pristine svn checkout as a basis, init a git repository, ignoring .svn directories; commit everything in svn head to your temporary git repository $ cd TMP $ git init && echo ".svn/" > .gitignore $ git add -A && git commit $ cd .. Copy the newly prepared git repository meta data to your original working directory; as the pristine subversion checkout directory is not needed, you can get rid of it. Your working directory is now both git and subversion repository: $ mv TMP/.git . $ rm -rf TMP/ You can now use powerful and convenient git add -p to interactively choose exactly what you want to share, and commit them to your git repository. If you need to add files to the commit, do also git add <file-to-add> before git commit $ git add -p <interactively select (and edit) the chunks you want to share> $ git add ${the_list_of_files_not_in_yet_in_svn_you_want_to_add} $ git commit Using the commit, prepare a patch that you want to share. For this purpose, you could also use git diff HEAD^..HEAD, or git format-patch (the latter can be used to directly prepare emails to be sent containing the patch or multiple patches): $ git show -p HEAD > my-mighty-patch.patch

要去除git元数据,只需执行rm -rf .git/。如果您计划继续使用原始工作目录,则可以继续使用git来管理本地更改。在这种情况下,您可能会从学习如何使用git svn中获益。

注意:如果你熟悉git,这是相当琐碎的事情即兴发挥。否则看起来可能有点乱。您可以根据这些步骤编写一个脚本来概括这种方法,为svn实现“交互式提交”或“交互式补丁创建”,这可以在不了解git的情况下使用。