Group Group Group Group Group Group Group Group Group

Page 186 why git rm can not delete JS folder

in your page 186, git rm -r js to remove js folder.

when I excute this command, it will delete files and sub directory under JS.

but folder JS itself still there, just become empty directory.

I tried other chapter’s magicSquareJS folder to git rm -r js to remove js folder.

some can remove entire JS folder, some still left empty JS foldler there.

weird , dont know why behavior like this.

Hi @yangwulong1978, this is something I’ve come across before and I’m ultimately not sure why this occurs. My best guess from what I’ve read online is it has something to do with git not tracking folders/directories only paths. I apologize in advance for not knowing more information about this but maybe someone who sees this can chime in.

Best,
Gina

Hi @yangwulong1978,

Yes, @gdelarosa guess is correct that this has to do with git not tracking folders and only paths.

So what happens is that if there are any ignored files, (likely .DS_Store), git rm won’t delete the folder. But if you remove the .DS_Store file first and then run the git rm command it will actually remove the folder as well.

The second edition of the book will just recommend running rm -rf js to avoid the confuses this causes.

Thanks,
Jawwad