git - 在纱线工作区中运行“git clean -xdf”时,跟踪文件被删除
问题描述
git clean -xdf
在带有 yarn 工作区的 repo 中运行时,工作区的内容将被删除。
考虑这个文件夹结构:
- 工作区1
- index.js
- 包.json
- 工作区2
- index.js
- 包.json
- .gitignore
- 自述文件.md
- 包.json
- 纱线锁
运行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")
解决方案
如果您使用的是 Windows,我敢打赌最可能的原因是以下问题:https ://github.com/git-for-windows/git/issues/607 。Git 确实在删除连接点的内容。
我可以使用“git version 2.22.0.windows.1”重现您的问题,但升级到“git version 2.23.0.windows.1”后不再看到它。
推荐阅读
- java - 通用的无锁同步
- flutter - 如何在没有firebase的情况下显示推送通知?
- typo3 - TYPO3 蒙版和背景图片
- sql - 在同一结果行上进行查询分组
- google-apps-script - 使用谷歌脚本根据列值在下面插入行
- mongodb - 如何替换mongodb项目语句中的字符串?
- dialogflow-es-fulfillment - Hangout Chat 中的快速回复按钮
- akka.net - Akka.net 调度程序只发送第一个值并且不更新它,如何修复它
- flutter - 如果其在键中具有相同的值,则合并数组中映射的值
- javascript - 在Angular 7中将选择模型表行传递给服务器