git-rm'ing all dead files
I couldn't find an easy way to remove all "dead" files from the index, i.e., call git-rm on all files that are missing from the working copy.
Here's the scenario: I moved/added/removed a lot of files using a GUI tool; now I need to reflect those changes in git. Using git-commit -a isn't the best choice because there are local modifications I don't want to commit. I can use "git add ." to automatically stage all new files, but how to the same for removed files?
-- Pazu
Hi,
Quoted 2 lines · Pazu
I couldn't find an easy way to remove all "dead" files from the index, i.e., call git-rm on all files that are missing from the working copy.
How about
git ls-files -z --deleted | git update-index -z --remove --stdin
?
Ciao,
Dscho
2007/1/24, Johannes Schindelin <[email protected]>:
Quoted 3 lines
How about
git ls-files -z --deleted | git update-index -z --remove --stdin
Aha. I was trying
git-ls-files -d | xargs git rm --cached
but most removed files contains spaces in their names, and that screwed git-rm up. I've even noticed the -z option on git-ls-files, but couldn't find one on git-rm, and I completely forgot about git-update-index.
Thanks, Johannes. This should do the trick.
-- Pazu
Hi,
Quoted 6 lines · Pazu
2007/1/24, Johannes Schindelin <[email protected]>:
Quoted 3 lines
How about
git ls-files -z --deleted | git update-index -z --remove --stdin
Quoted 8 lines
Aha. I was trying
git-ls-files -d | xargs git rm --cachedbut most removed files contains spaces in their names, and that screwed git-rm up. I've even noticed the -z option on git-ls-files, but couldn't find one on git-rm, and I completely forgot about git-update-index.
You _can_ use
git ls-files -z -d | xargs -0 git rm --cached
So, you did not find that option with git-rm, because it is an option to xargs...
Ciao,
Dscho
2007/1/24, Johannes Schindelin <[email protected]>:
Quoted 6 lines
You _can_ use
git ls-files -z -d | xargs -0 git rm --cachedSo, you did not find that option with git-rm, because it is an option to xargs...
I remember trying that, but git-rm was still confused about spaces in filenames. I'll try it again the next time I'm in a situation like that.
-- Pazu