linux - 从 git 中删除不存在的文件

标签 linux git symfony unix ubuntu

git status给出的信息有:

git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)

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

"src/HomeBundle/Entity/\320Apartments.php"
"src/HomeBundle/Repository/\320ApartmentsRepository.php"
"src/HomeBundle/Resources/config/doctrine/\320Apartments.orm.yml"

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

我想从我的计算机中删除这些文件,因为它们是我不小心创建的

我尝试执行:

git rm "src/HomeBundle/Entity/\320Apartments.php"
fatal: pathspec 'src/HomeBundle/Entity/\320Apartments.php' did not match any files

git rm '"src/HomeBundle/Entity/\320Apartments.php"'
fatal: pathspec '"src/HomeBundle/Entity/\320Apartments.php"' did not match any files

rm '"src/HomeBundle/Entity/\320Apartments.php"'
rm: cannot remove ‘"src/HomeBundle/Entity/\\320Apartments.php"’: No such file or directory

rm "src/HomeBundle/Entity/\320Apartments.php"
rm: cannot remove ‘src/HomeBundle/Entity/\\320Apartments.php’: No such file or directory

git rm '"src//HomeBundle//Entity//\320Apartments.php"'
fatal: pathspec '"src//HomeBundle//Entity//\320Apartments.php"' did not match any files

git rm "src//HomeBundle//Entity//\320Apartments.php"
fatal: pathspec 'src//HomeBundle//Entity//\320Apartments.php' did not match any files

rm '"src//HomeBundle//Entity//\320Apartments.php"'
rm: cannot remove ‘"src//HomeBundle//Entity//\\320Apartments.php"’: No such file or directory

请帮我找到并删除它们!

最佳答案

你不需要像“src//...”中那样的双斜杠

您正在使用 linux 终端,因此您可能正在使用 bash。尝试自动完成:

rm src/H<tab><tab>

  • 你写rm src/H然后按 Tab 键两次,它将完成到“src/HomeBundle”,然后添加“/E”并按 Tab 键两次。这将帮助您在必要时自动完成路径和转义字符。

关于linux - 从 git 中删除不存在的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37688935/

相关文章:

c - 文件描述符存储在进程内存中的什么位置?

linux - 递归删除 x64 程序集中的文件

symfony - 如何显示 404 错误页面而不是 Symfony4 中的错误

php - Twig:如何四舍五入?

Symfony2 - Twig - 显示数据的问题

c++ - 将libpcap添加到mipsel时交叉编译出错

java - org.hibernate.hql.internal.ast.QuerySyntaxException : <table_name> is not mapped [from <table_name>]

git - 将 git 钩子(Hook)添加到谷歌云存储库

git - .gitignore 提交后

git - 如何使用 ssh 代理通过 Maven 进行 git 克隆?