撤消'dvc add'操作

  • 本文关键字:操作 add dvc 撤消 dvc
  • 更新时间 :
  • 英文 :


dvc add了一个我不想添加的文件。我还没有承诺。

如何撤消此操作?在 Git 中,你会做git rm --cached <filename>.

需要明确的是:我想让DVC忘记文件,我希望文件在我的工作树中保持不变。这与dvc remove所做的相反。

DVC 问题跟踪器上的一个问题表明dvc unprotect是正确的命令。但阅读手册页表明并非如此。

DVC可以做到这一点吗?

根据 DVC Discord 服务器上的 mroutis:

  1. dvc unprotect文件;如果您不使用symlinkhardlink缓存,则不需要这样做,但这不会造成伤害。
  2. 删除 .dvc 文件
  3. 如果需要删除缓存条目本身,请运行dvc gc,或在data.dvc中查找 MD5 并将其手动从.dvc/cache中删除。

编辑- 他们的Github页面上现在有一个问题,可以将其添加到手册中:https://github.com/iterative/dvc.org/issues/625

dvc remove似乎可以满足未提交文件的需求 - 至少对于不在管道中的文件。关键(我从错误或文档中不清楚(是传递….dvc文件名,否则它会尝试从dvc.yaml中找到并将其作为部分删除。

# Precondition: DVC is configured for the repo. No dvc.yaml file (untested with it)
$ touch so-57966851.txt
$ dvc add so-57966851.txt
WARNING: 'so-57966851.txt' is empty.                                                                                                                          
100% Adding...|████████████████████████████████████████|1/1 [00:00, 49.98file/s]
                                                                                        
To track the changes with git, run:
git add .gitignore so-57966851.txt.dvc
# Ooops! I did the wrong thing! I didn't mean to add that…
$ dvc remove so-57966851.txt.dvc
$ ll so-*.txt
-rw-r--r-- 1 ibboard users 0 Aug 23 20:27 so-57966851.txt

(与 v2.5.4 兼容(

相关内容

最新更新