Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJamie Reardon
Treehouse Project ReviewerWhat about removing files out of a subdirectory?
So I understand about the git rm subcommand removing files, but what I encountered is that if I had folders inside of my git repo, if I remove any files inside of those folders, the whole folder is also removed? How do I keep the folders but only remove the files?
Thanks.
1 Answer
Jay McGavren
Treehouse TeacherGit will not track an empty folder. If you have a folder that you want to keep, try creating and committing a file named .gitkeep
inside it.
Jamie Reardon
Treehouse Project ReviewerJamie Reardon
Treehouse Project ReviewerHey Jay, I actually found out on workspaces that if I have more than one file in a subdirectory, then it will only delete the file with the command: git rm.
If you have only one file, then the entire subdirectory with that file will be deleted. I shown this to Brian Jensen in the slack app of the techdegree and he found it weird behaviour.
Jay McGavren
Treehouse TeacherJay McGavren
Treehouse TeacherJamie Reardon Weird, perhaps, but that's the standard Git behavior.
git rm mydir/a.txt
removesmydir
on my Mac as well.Jamie Reardon
Treehouse Project ReviewerJamie Reardon
Treehouse Project ReviewerAh I see, didn't know that as I didn't see you mention it on the videos. Thanks for the clarification! I have finished this course and I enjoyed it thoroughly, I am now studying the expanded course of the Git: Branches and Merging by yourself. Thanks :)