我dvc add
了一个我不想添加的文件。我还没有承诺。
如何撤消此操作?在 Git 中,你会做git rm --cached <filename>
.
需要明确的是:我想让DVC忘记文件,我希望文件在我的工作树中保持不变。这与dvc remove
所做的相反。
DVC 问题跟踪器上的一个问题表明dvc unprotect
是正确的命令。但阅读手册页表明并非如此。
DVC可以做到这一点吗?
根据 DVC Discord 服务器上的 mroutis:
dvc unprotect
文件;如果您不使用symlink
或hardlink
缓存,则不需要这样做,但这不会造成伤害。- 删除 .dvc 文件
- 如果需要删除缓存条目本身,请运行
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 兼容(