Git won't track empty directories (because at heart it only tracks files).
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat@hachyderm.io yes. this.
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat I think I like this better. It at least gives you the ability to explain purpose instead of just hacking git to follow it.
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat this feels so obvious and I never thought of it, so thanks for the tip. To be fair to myself, I only resorted to using a .gitkeep once ever
-
@nedbat But what do you do when all files from a folder are deleted in a certain commit. Leave a readme that this folder was once there for some kind of reason? Otherwise all people who once had pulled that commit end up with an empty folder that's not used for any thing...
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat
One thing I started doing a few years ago is to add a .gitignore file that contains!.gitignore
*Instead of the wildcard, you can also list the specific things you want to ignore. Of course, a few comments about why you ignore what or why this exists helps as well
. -
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
Better yet, make your project not rely on having an empty directory. If you need one, create it at runtime instead.
-
@nedbat
One thing I started doing a few years ago is to add a .gitignore file that contains!.gitignore
*Instead of the wildcard, you can also list the specific things you want to ignore. Of course, a few comments about why you ignore what or why this exists helps as well
.@nedbat
The gitignore serves then as both documentation and the replacement for .gitkeep -
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat I just did just yesterday while debugging, and then added an ASCII cow because why not
-
Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.
EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.
@nedbat lol i did that for work once and was told to use .gitkeep instead

-
S skorpy@chaos.social shared this topic