首页 > 解决方案 > 如何使用 git bash 删除 ~$ 文件(在 Windows 上)

问题描述

即使使用“显示隐藏对象”设置,我也看不到已探索的文件。另一方面,git 将其显示为未跟踪的文件,我发现无法删除它。

有任何想法吗?

git status
On branch devSQC
Your branch is up to date with 'origin/devSQC'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        pathto/~$crazy file.xlsx

nothing added to commit but untracked files present (use "git add" to track)


ls pathto/
'~$crazy file.xlsx'

git rm -f 'pathto/~$crazy file.xlsx'
fatal: pathspec 'pathto/~$crazy file.xlsx' did not match any files

我知道这些是用于恢复的 windows 文件,但 windows 也不允许做任何事情,我希望 git bash 更好;-) 参见例如这里,但我希望,我不需要安装额外的工具......

标签: windowsgit-bash

解决方案


我刚刚意识到,在 bash 中删除这些文件很简单(当然,它与 git 无关......)

cd path2/
rm -f '~$FHS_Noten STAT_FS2019_TZ17_Noten_Vorlage.xlsx'

git-rm不起作用,因为它

从工作树和索引中删除文件

所以它不是删除文件的功能。


推荐阅读