GIT,无法进行提交

时间:2014-08-26 10:04:42

标签: git

在我的工作目录中,我删除了一张图片。 问题是,我无法进行提交(添加或删除)。

$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified:   ...

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:    "public/images/logo-pb\357\200\242old.png"

每次我尝试这些命令(甚至用引号):

git add public/images/logo-pb\357\200\242old.png
git rm public/images/logo-pb\357\200\242old.png

它总是告诉我:

fatal: pathspec 'public/images/logo-pb357200242old.png' did not match any files

3 个答案:

答案 0 :(得分:0)

我不确定,但问题可能在于逃避&#39; \&#39;字符。 你应该尝试命令

git add public/images/logo-pb\\357\\200\\242old.png

答案 1 :(得分:0)

git rm $(git ls-files --deleted)将帮助您

git ls-files --deleted提供了从存储库中删除文件的路径 并git rm将删除它们。

答案 2 :(得分:-1)

您使用的是什么版本的git?使用我的版本(1.9.4.msysgit.0),我会删除assembly.xml

C:\projects\Project\src\main\assembly>git add assembly.xml
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'src/main/assembly/assembly.xml' that are
removed from your working tree are ignored with this version of Git.

* 'git add --ignore-removal <pathspec>', which is the current default,
  ignores paths you removed from your working tree.

* 'git add --all <pathspec>' will let you also record the removals.

Run 'git status' to check the paths you removed from your working tree.

当我跑步时

git add -A assembly.xml

它不再抱怨了。