gpt4 book ai didi

git状态说文件被删除但是git rm说错误: pathspec '.....' did not match any files

转载 作者:太空狗 更新时间:2023-10-29 13:49:41 24 4
gpt4 key购买 nike

我已经这样做了 100 多次。我从目录中删除了一个文件,然后运行看起来不错的 git status。

# 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: themes/custom/gitb/templates/views-view-field--field-overall-rating.tpl.php
#

然后我跑git rm themes/custom/gitb/templates/views-view-field--field-overall-rating.tpl.php并收到错误信息

error: pathspec 'themes/custom/gitb/templates/views-view-field--field-overall-rating.tpl.php' did not match any file(s) known to git.

git status“知道”这个文件,但是 git rm 不知道也不会删除它。我被卡住了,该如何解决?

最佳答案

一个快速而肮脏的解决方案是添加回文件并使用

git rm themes/custom/gitb/templates/views-view-field--field-overall-rating.tpl.php

删除它。

git rm 也会从文件系统中删除文件,因此您不需要(通常也不应该)手动删除文件。

编辑

一个更简洁的方法是让 git 注意到丢失的文件使用

git add -u

git commit -a

来自 git-add 的文档,这里是 -u 选项的描述

Only match against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.

这是 git-commit

-a 选项

Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.

关于git状态说文件被删除但是git rm说错误: pathspec '.....' did not match any files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14444245/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com