【问题标题】:git status shows unexisting untracked filegit status 显示不存在的未跟踪文件
【发布时间】:2018-11-14 09:18:06
【问题描述】:

我不知道这个问题是应该移到ServerFault还是它属于这里!

在远程 Unix 服务器上工作,我使用 FileZilla 创建了一个文件 file_x.php。

我在终端上使用GIT。

当我执行git status 时,它会告诉我:

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
  some_other_file1.php
  some_other_file2.php
   file_x.php
  ^
  |__ Note this weird blank space

问题:我想删除这个文件,我从FileZilla 尝试过,但没有成功,它显示了there is no such file or directory!但文件始终存在!

所以我尝试了:

rm -rf file_x.php       # This didn't work
sudo rm -rf  file_x.php # I'm not from the sudoers
git checkout file_x.php # This didn't do a thing !
git clear -f            # This didn't do a thing !
git rm file_x.php
==> fatal: pathspec 'file_x.php' did not match any files

我的问题,这是什么意思?以及如何删除此文件?

【问题讨论】:

  • 那个“奇怪”的空白一点也不奇怪。它是文件名的一部分。如果它是常规空格,那么每次将文件名(包括前导空格)放入命令行(任何命令行)时,您都可以将其包装成引号(")或撇号(')。 F.e. git rm " file_x.php".

标签: linux git shell


【解决方案1】:

你必须逃离这个空间:

rm \ file_x.php

【讨论】:

  • @HamzaAbdaoui,如果这解决了您的问题,请勾选此答案,这是在 StackOverflow 上感谢某人的最有效方式
  • @DudeCoder,哈哈哈是的,我知道,只是我不得不等待 7 分钟:P
猜你喜欢
  • 2011-06-04
  • 2019-10-30
  • 2013-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-31
  • 1970-01-01
  • 2015-05-03
相关资源
最近更新 更多