仅从工作副本中删除文件,而不是从存储库中删除文件 [英] Delete file from the working copy only but not from the repository

查看:30
本文介绍了仅从工作副本中删除文件,而不是从存储库中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我无法在网络上的任何地方找到上述问题的答案,所以我自己提供了解决方案.这是一个手动过程,但我找不到任何其他标准解决方案.所以这里是:

Since I could not find the answer of the above question anywhere in the web, I come with the solution myself. It's a manual process but I couldn't find any other standard solution. So here it is:

假设您要从目录 work 中删除文件 test.txt.现在,如果您通过

Suppose you want to delete the file test.txt from directory work. Now if you delete test.txt forcefully by

rm -rf 测试.txt

rm -rf test.txt

命令然后在 work 目录(或其任何父目录)上的下一个 svn 上,文件将被恢复.所以诀窍是从 .svn/entries 文件中删除它,以及.因此,仅从工作副本中删除 test.txt 的完整命令序列是:

command then on the next svn up on the work dir (or any of its parent-directories), the file will be restored. So the trick is to delete it from .svn/entries file, as well. Thus the complete sequence of commands for deleting test.txt only from working copy is:

cd work
rm -rf test.txt
svn st     #it shows ! sign beside test.txt which means that 
       #in the next **svn up** it will be restored
chmod u+w .svn/entries
vi .svn/entries
#delete the lines associated with test.txt
#you need to delete the following 3 lines from .svn/entries
#test.txt
#file
#^L
svn st #it doesn't report test.txt anymore

推荐答案

lallafa 报告 一个很好的方法,基于所谓的稀疏目录:

lallafa reports a good method, based on something called sparse directories:

svn update --set-depth exclude <folder-to-delete>

  • 不错
  • 简单
  • 处理文件
  • 不好:

    • 我想这不会帮助您避免检查您拥有的 GB 数据(尽管您可以尝试这个.)
    • 不适用于切换的目录(可能会或可能不会进行一些工作,未经测试)
    • 在大型目录上,这不是一个好主意.od_m3 说在 190 GB 工作副本上,使用 svn 1.6 这种方法需要 1 小时,但在svn 1.7 花了 50 多个小时.这是在 2011 年.
    • I guess won't help you avoid checking out GBs of data you have (although you could try this.)
    • doesn't work on switched directories (may or may not with a little work, not tested)
    • on large directories, not a very good idea. od_m3 says that on a 190 GB working copy, with svn 1.6 this method tooks 1 hours, but on svn 1.7 it tooks more than 50 hours. This was in 2011.

    来源添加:

    如果你以后想再次使用那个目录,你可以这样做

    if you later want to use that directory again, you can do

    svn update --set-depth=infinity <folder-to-delete>
    

    我希望我知道如何以这种方式列出已经排除"的目录,因为 st 不会显示它们.:D

    I wish I knew how can I list directories already "excluded" this way, because st won't show them. :D

    来自名为Mike5"(或 jed/jeds)的人的相同来源,适用于目录:

    对于每个要避免更新的目录,请执行

    for every directory you want to avoid updating, do

    svn switch --ignore-ancestry http://dummy/exists/but/empty_folder some_folder
    

    • some_folder 替换为您要忽略的文件夹.
    • 还将 http://dummy/exists/but/empty_folder 替换为您存储库中的现有路径,该路径是一个空目录,永远不会更新或删除 - 据称为此目的而创建和专用.
      • replace some_folder with the folder you want to ignore.
      • also replace http://dummy/exists/but/empty_folder with an existing path in your repository which is an empty directory, will never be updated nor deleted - supposedly created and dedicated for this purpose.
      • 这样,您将实现:

        • 切换的目录不再在工作副本中更新
        • 对实际存储库没有更改

        您将不会实现:

        • 文件中的任何内容
        • 目录不会消失/被删除(从文件列表中)
        • 摆脱对这些目录的初始检出,除非您使用 --depth 对立即数"进行检出,首先,执行此操作,然后继续检出(未测试).
        • 我想您无法摆脱下载已经拥有(未经测试)的 GB 数据.
        • anything on files
        • the directory won't disappear/be deleted (from file listing)
        • getting rid of initial checking out of these directories, unless you do a checkout for 'immediates' with --depth, first, do this, and then continue the checkout (not tested).
        • I guess you cannot get rid of downloading GBs of data you already have (not tested).

        在专用的空目录上使用 svn propset svn:ignore "*" empty_folder 也是一个好主意,所以没有人可以向它提交任何内容.

        It is also a good idea to use svn propset svn:ignore "*" empty_folder on the dedicated empty directory, so noone can commit anything to it.

        这篇关于仅从工作副本中删除文件,而不是从存储库中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆