【发布时间】:2019-09-09 13:30:48
【问题描述】:
在带有 yarn 工作空间的 repo 中运行 git clean -xdf 时,工作空间的内容会被删除。
考虑这个文件夹结构:
- 工作区1
- index.js
- package.json
- 工作区2
- index.js
- package.json
- .gitignore
- README.md
- package.json
- yarn.lock
运行git clean -xfd 后,粗体文件(跟踪的源代码控制文件)被删除!即使 clean 根本不应该影响被跟踪的文件。
我相信这是一个纱线工作区错误。我打开了一个问题@yarn: https://github.com/yarnpkg/yarn/issues/7536
有人遇到过这个问题吗?有没有人有解决方法或知道这种行为的根本原因?
对于有兴趣直接查看该错误的任何人,我创建了一个可以轻松重现该错误的存储库: https://github.com/Shmulik-Kravitz/yarn-with-git-bug
复制步骤在里面。
yarn --verbose 的输出(很长):
https://github.com/Shmulik-Kravitz/yarn-with-git-bug/blob/master/yarn%20log
git clean -xdf 的输出:
Removing node_modules/
git status 的输出:
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: workspace1/index.js
deleted: workspace1/package.json
deleted: workspace2/index.js
deleted: workspace2/package.json
no changes added to commit (use "git add" and/or "git commit -a")
【问题讨论】:
-
你能把文件添加到.gitignore吗?
-
我不清楚你认为这个错误是什么。哪些文件被删除了,你为什么不希望它们被删除?他们被跟踪,干净,......?
private属性消息与其余消息有何关系? -
我已经编辑了问题。
-
这居然重现!我不知道为什么...我做了克隆、纱线(在根目录下)、git clean -xdf 并且这些文件被 git-clean 删除了
-
请描述重现问题本身的错误的确切步骤,而不是链接到外部站点。另外:(1)如果您使用
--verbose运行纱线,输出是什么? (2)git status运行yarn前后的输出是什么?
标签: git yarnpkg yarn-workspaces