I renamed a directory from tools to Tools and commited. After this I have two directory in my remote. So for some reason git did not remove the tools directory. How to prevent this or fix the current issue?
You renamed a directory without informing git about it, and hence git considered your Tools directory as a fresh new directory and added it to version control.
To fix the issue, you could ask git to delete the older directory named tools:
git rm -r tools
git commit
An alternative would be git add -u, which checks the current state of your working directory and updates the staging area to reflect this state. So git would become aware of any directories that were removed behind its back.
# From the root of your repo
git add -u .
git commit
And for the future, use git mv to perform the rename, instead of performing the rename directly in the Shell or Command prompt. Although git is smart enough to track the move if it finds a significant similarity between deletions and additions, I prefer informing git explicitly about the move operation.
git mv tools Tools
git commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With