GIt状态说文件被删除,但git rm说errror:pathspec'.....'与任何文件都不匹配 [英] GIt status says file is deleted but git rm says errror: pathspec '.....' did not match any files

查看:328
本文介绍了GIt状态说文件被删除,但git rm说errror:pathspec'.....'与任何文件都不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了这100次。
我从一个目录中删除了一个文件,然后运行git status,这看起来很好。

 #没有为commit提交的更改:
#(使用git add / rm< file> ...更新将要提交的内容)
#(使用git checkout - < file> ...更改工作目录)

#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
并收到错误消息

 错误: pathspec'themes / custom / gitb / templates / views-view-field-field-overall-rating.tpl.php'与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 

$ b

git-add 的文档中,以下是<$ c



只匹配索引
中已经跟踪的文件,而不是工作树。这意味着它永远不会展示新的
文件,但它会逐步修改跟踪文件
的新内容,并且它会从索引中删除文件,如果相应的
文件在

以下是 -a 中的一个。 code> git-commit


告诉命令自动登台已修改
并已删除的文件
,但未告知git的新文件不受
的影响。



I've done this 100s of times. I deleted a file from a directory and then run git status which looks fine.

# 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 
#

Then I run git rm themes/custom/gitb/templates/views-view-field--field-overall-rating.tpl.php and receive an error message

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 "knows" about the file but but git rm doesn't and won't remove it. I'm stuck and how do I solve this?

解决方案

A quick and dirty solution would be to add back the file and use

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

to remove it.

git rm removes the file from the filesystem too, so you don't need (and in general you shouldn't) to manually remove the file.

EDIT

A cleaner way to do so, would be to make git to notice the missing file using

git add -u

or

git commit -a

From the doc of git-add, here's the description of the -u option

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.

and here's the one for the -a option of git-commit

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说errror:pathspec'.....'与任何文件都不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆