git - how to remove empty folder and push that change?
Solution 1:
The short answer: You can't push changes to directories (added, removed, etc.) because Git does not track directories on their own.
According to the FAQ:
Currently the design of the git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.
So as far as Git is concerned, your empty directory doesn't exist anymore.
I have found that getting in the habit of using git clean -fd
removes the need for pushing the removal of directories. However, git clean
can remove items you may not want removed (including any new files you have not yet committed) so I tend to first use git clean -fdn
to see what will be removed if I use the command.
It looks like you may be forced to talk to your fellow developers in order to clean up that directory.
Solution 2:
git add --all
git clean -f -d
git commit -m "trying to remove folders"
git push