如何优雅地取消 SVN 中文件的版本(不打扰团队成员)?
这个问题的变体以前曾被问过,但似乎没有提到打扰其他团队成员的问题。在现有帖子中(请参阅如何“取消版本” svn 和/或 git 中的文件)接受的答案通常是运行 svn rm FILE
或 svn rm --keep-local FILE
,然后如果需要,设置 svn:ignore 属性。我花了最后 20 分钟来解决这个问题(在两个地方检查一个存储库,从一个地方删除一个文件,然后更新另一个地方,等等)。这是我发现的内容(我使用的是 SVN 1.6.16):
首先,据我所知, --keep-local 标志不会影响随后从存储库更新的其他人所发生的情况。对他们来说,它看起来就像你刚刚做了一个常规的 svn delete 一样(我见过的任何颠覆文档都没有明确提到这一点 - 也许很明显你仍然在做一个>svn delete
操作并且“保持本地”只会影响本地端的内容,但这对我来说不一定很明显)。
因此有两种情况 - 1. 团队成员 A 删除了团队成员 B 没有进行本地修改的文件,或者 2. 团队成员 A 删除了团队成员 B 未提交本地更改的文件。
1、删除之后B的文件就被删除了。他现在必须自己恢复它(即 svn merge -rHEAD:XXX FILE; svn revert FILE
将 FILE 的版本 XXX 放回到工作目录中,并且下次不会重新提交它提交)
在 2 中,B 在更新时看到树冲突,并且 FILE 现在的状态为 A + C,其下方有消息“本地编辑,更新时传入删除”。目前,我不太确定推荐的解决方案是什么。为了安全起见,我所做的是将 FILE 复制到其他地方,然后运行 svn revert FILE。它最终是不必要的,因为 FILE 仍然存在于工作目录中,并且所有本地修改都完好无损。但我不知道我有多相信这一点,因为我在其他情况下已经通过 svn revert 删除了未提交的更改。
tl;dr:在 SVN 中取消文件版本的唯一方法是否真的是从团队中其他人的工作目录中删除它,然后使他们自己取回吗?我是否使用了 --keep-local 错误,或者缺少另一个类似的选项?
Variations of this question have been asked before, but it seems like the issue of disturbing other team members hasn't been mentioned. In existing posts (see How to "unversion" a file in either svn and/or git) the accepted answer is generally to run svn rm FILE
or svn rm --keep-local FILE
, and then set the svn:ignore
property if desired. I've spent the last 20 minutes playing around with this (checking out a repo in two places, deleting a file from one, then updating the other, etc.). Here's what I found (I'm using SVN 1.6.16):
First of all, from what I can tell the --keep-local flag doesn't affect what happens to everyone else who is going to update from the repository afterwards. To them it looks the same as if you had just done a regular svn delete
(none of the subversion documentation I have seen mentions this explicitly - maybe it should be obvious that you're still doing an svn delete
operation and that "keep local" will only affect things on the local side, but it wasn't necessarily obvious to me).
So there are two cases - 1. team member A deletes a file that team member B had no local modifications in or 2. team member A deletes a file that team member B did have uncommitted local changes in.
In 1, after the delete takes place B's file has been deleted. He now has to recover it on his own (i.e. svn merge -rHEAD:XXX FILE; svn revert FILE
to get version XXX of FILE back into the working directory and have it not be re-committed at next commit)
In 2, B sees a Tree Conflict on updating, and FILE now has a status of A + C
with the message "local edit, incoming delete upon update" below it. At this point, I'm not exactly sure what the recommended solution is. What I did is copy FILE somewhere else, just to be safe, and then ran svn revert FILE
. It ended up being unnecessary because FILE still exists unversioned in the working directory with all local modifications intact. But I don't know how much I trust this, as I've had my uncommitted changes erased by svn revert
in other scenarios.
tl;dr: Is it really the case that only way to un-version a file in SVN is to delete it from the working directory of everyone else on the team and make them retrieve it themselves? Am I using --keep-local wrong, or missing another similar option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将要删除的所有文件添加到忽略列表(使用 TortoiseSVN 很容易 -> 使用“删除并添加到忽略列表”选项)并提交。
现在进行删除。
另一种选择是执行 svndumpfilter,如下所述: 如何从 svn 版本控制中删除文件而不从每个工作副本中删除它?
You have to add all the files you are deleting to the ignore list ( easy with TortoiseSVN -> use Delete and add to ignore list option ) and commit that.
Now do the delete.
Another option is to do a svndumpfilter, as mentioned here: How do I remove a file from svn versioning without deleting it from every working copy?
文件一旦进入 Subversion 存储库,就永远无法完全删除。当然,您可以执行 svn rm 并提交以从该分支的最新副本中删除该文件,但该文件仍然存在。在文件被删除之前检查修订版本的任何人都将看到该文件。并且,您可以通过在目录树上运行
svn log
轻松找到已删除的文件。如果您不小心添加了包含专有信息(例如客户的登录名和密码)或不适当的文件,您无能为力(我们有一位开发人员不小心签入了他在自己的文件中的 gif)工作空间,后来导致他自愿离开公司,然后才成为非自愿行为。)。
您的选择如下:
svnadmin dump
。使用 svnfilter 将转储通过管道传输到 svnadmin load 以创建不含不受欢迎的文件的存储库的新版本。--keep-local
标志仅在svn delete
后保留文件的本地副本。默认情况下,通过svn delete
从工作区本地删除文件。Once a file is in the Subversion repository, it can never be completely removed. Sure, you can do a
svn rm
and commit to remove the file from the most recent copy of that branch, but the file is still there. Anyone checking out the revision before the file was deleted will see the file. And, you can easily find the deleted file by running asvn log
on the directory tree.There's not much you can do if you accidentally added a file that contains proprietary information (such as a customer's login and password) or is inappropriate, (we had one developer accidentally check in a gif he had in his workspace which later caused him to voluntarily leave the company before it became an involuntary act.).
Your choices are as followed:
svnadmin dump
. Usesvnfilter
to pipe the dump to asvnadmin load
to create a new version of the repository sans the unloved file.svn obliterate
command. (Actually, checking the roadmap, it's not in version 1.8 anymore. Maybe 1.9?).The
--keep-local
flag merely keeps a local copy of the file after ansvn delete
. The default is to remove the file locally from your workspace upon ansvn delete
.