committing selected 'changed' or 'added' files works, but not 'removed'
- From
Jim Meyering <jim@meyering.net>
- Date
- May 14, 2007, 06:16 UTC
- Message-ID
- <87y7jsgcag.fsf@rho.meyering.net>
Hello,
If I've just run "git-rm -f c" in a directory with a few modified or git-added files, is there some way to commit (non-interactively) only the removal of that selected file? I.e., not any other changes in the working directory? git-commit -m. -- c fails with this:
error: pathspec 'c' did not match any file(s) known to git
If I use "cg-commit" instead of "git-commit", it works fine.
When I asked on IRC, "cehteh" suggested to create a temporary branch, do the removal there, and then to rebase that change back onto the original branch -- and to remove the disposable branch. Yes, that works, but I want do the job with a single commit command, the same way I can for "added" and "modified" files. And I've been trying (until now, successfully) to wean myself away from cogito.
Why should "removed" files be handled so differently? If I cannot commit a selected "file removal" (regardless of the state of the index), then isn't that an opportunity to add a feature?
In case you're wondering, I want this functionality in order to make a version control agnostic commit/diff/ChangeLog tool work the same way with raw git as it did using cogito.
------------------------------------------- In case an actual scenario helps, I'd like to be able to commit the removal of "c", below without also committing the change to "b":
mkdir .j && cd .j && git-init > /dev/null && touch b c && git-add b c \ && git-commit -q -m. && echo > b && git-rm --quiet -f c \ && git-commit -m. -- c
The final commit above fails like this:
error: pathspec 'c' did not match any file(s) known to git. Did you forget to 'git add'?