简体   繁体   English

在提交之前“取消添加”一个文件到 svn

[英]“unadd” a file to svn before commit

I was in the middle of doing a recursive svn add/commit, and a folder which did not have the proper ignore properties was included.我正在执行递归 svn add/commit,并且包含一个没有正确忽略属性的文件夹。 I've got about 100 uploaded binary files versioned now, but I haven't committed yet.我现在有大约 100 个上传的二进制文件版本化,但我还没有提交。

What is the easiest way to 'undo' this, without deleting all the documents?在不删除所有文档的情况下,“撤消”此操作的最简单方法是什么?

Use svn revert --recursive folder_name使用svn revert --recursive folder_name


Warning警告

svn revert is inherently dangerous, since its entire purpose is to throw away data — namely, your uncommitted changes. svn revert本质上是危险的,因为它的全部目的是丢弃数据——即你未提交的更改。 Once you've reverted, Subversion provides no way to get back those uncommitted changes.一旦您恢复,Subversion 将无法恢复那些未提交的更改。

http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.revert.htmlhttp://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.revert.html

svn rm --keep-local folder_name

Note: In svn 1.5.4 svn rm deletes unversioned files even when --keep-local is specified.注意:在 svn 1.5.4 中,即使指定了 --keep-local,svn rm 也会删除未版本控制的文件。 See http://svn.haxx.se/users/archive-2009-11/0058.shtml for more information.有关更多信息,请参阅http://svn.haxx.se/users/archive-2009-11/0058.shtml

Try svn revert filename for every file you don't need and haven't yet committed.尝试svn revert filename为您不需要且尚未提交的每个文件。 Or alternatively do svn revert -R folder for the problematic folder and then re-do the operation with correct ignoring configuration.或者,对有问题的文件svn revert -R folder执行svn revert -R folder夹,然后使用正确的忽略配置重新执行操作。

From the documentation:从文档:

 you can undo any scheduling operations:

$ svn add mistake.txt whoops
A         mistake.txt
A         whoops
A         whoops/oopsie.c

$ svn revert mistake.txt whoops
Reverted mistake.txt
Reverted whoops

Full process (Unix svn package):全过程(Unix svn 包):

Check files are not in SVN:检查文件不在 SVN 中:

> svn st -u folder 
? folder

Add all (including ignored files):添加所有(包括忽略的文件):

> svn add folder
A   folder
A   folder/file1.txt
A   folder/folder2
A   folder/folder2/file2.txt
A   folder/folderToIgnore
A   folder/folderToIgnore/fileToIgnore1.txt
A   fileToIgnore2.txt

Remove "Add" Flag to All * Ignore * files:删除“添加”标志到所有 * 忽略 * 文件:

> cd folder

> svn revert --recursive folderToIgnore
Reverted 'folderToIgnore'
Reverted 'folderToIgnore/fileToIgnore1.txt'


> svn revert fileToIgnore2.txt
Reverted 'fileToIgnore2.txt'

Edit svn ignore on folder编辑 svn 忽略文件夹

svn propedit svn:ignore .

Add two singles lines with just the following:添加两条单打线,只需以下内容:

folderToIgnore
fileToIgnore2.txt

Check which files will be upload and commit:检查哪些文件将被上传和提交:

> cd ..

> svn st -u
A   folder
A   folder/file1.txt
A   folder/folder2
A   folder/folder2/file2.txt


> svn ci -m "Commit message here"

For Files - svn revert filename对于文件 - svn revert filename

For Folders - svn revert -R folder对于文件夹 - svn revert -R folder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM