← Notes

git rm Takes the Parent Directory Too

1 min read#Git

I meant to remove a single file and ended up with thirty-six marked deleted.

When you remove the last file in a directory, git removes the whole directory with it, and status just shows a run of deleted lines that is easy to skim past. I meant to delete one file; when I looked at status again, 36 files were marked deleted.

The reverse is just as dangerous: reverting a directory throws away every uncommitted change under it, including the ones I had just made.

Written byShihao Qi