I'm trying to stage individual files for delete, but git (v1.9.1) refuses to stage them because the folder where they used to reside has already been deleted.
I cannot use git add -u
because it will stage all modified and deleted files. If I do
git add -u /path/to/deleted/folder/afile
or
git rm /path/to/deleted/folder/afile
I get:
fatal: Could not switch to '/path/to/deleted/folder/': No such file or directory
Which is because /path/to/deleted/folder/
no longer exists.
I cannot understand why git needs to switch to a directory when being told to stage deleted files and having to manually recreate each deleted folder just to let git know, that yes, the file really is gone seems insane.
Is there a way of forcing git to stage a deleted file without requiring the path to exist?
With all credit to Wolf and ROMANARMY, upgrading to 2.5 allows git rm
to succeed.
Just in case anyone else cares, here's how I upgraded my Ubuntu 14.04 from the default git to 2.5:
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
$ git --version
git version 2.5.0