I accidentally added a bunch of cache files into the repo. I've now removed them and now want to commit the change to the repo.
So I tried to do the following, but git doesn't seem to like it:
git diff --name-only | grep '/cache/' | xargs git add
Error:
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 'sym_online_app_bs3/cache/demo_cust_can_create_tickets' 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.
I don't want to git add --all
because there are some other changes I don't want committed yet.
Has anybody had to do something similar and have a solution to this.
Thanks
I'm on: Darwin Kernel Version 13.4.0 (Mac OSX 10.9.5)
Update
Git interactive is an acceptable alternative for now. But would be interested to find out how to go down the xargs route.
git -i
and
are different.
So,
is what you want. Additionally,
git add
can take multiple arguments on the command line, so what you want can be done withInstead of using grep use the
-G
option of thegit diff
command: