简体   繁体   中英

GIT, not able to stage for commit

Inside my working directory I deleted an image. The problem is, I'm not able to stage it for commit (add or remove).

$ 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"

Every time I try these commands (even with quotes):

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

It always tells me:

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

I am not sure, but the issue might be with escaping '\\' character. You should try the command

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

git rm $(git ls-files --deleted) will help you as

git ls-files --deleted gives path to deleted files from repository and git rm will remove them.

What version of git you use? With my version ( 1.9.4.msysgit.0 ) I get for deleted 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.

And when I run

git add -A assembly.xml

it doesn't complain anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM