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.
-
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, but if you put README in there it's no longer empty, and if it must be empty, then that is not going to work :-).
-
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 usually have a
.gitignorefile with the following data:*
!.gitignore -
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 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@hachyderm.io Another option that'd often (but maybe not always) be preferable: create the directory when it's needed, e.g. during build.
-
P pixelate@tweesecake.social shared this topic
-
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 Solid advice!
-
@nedbat I usually have a
.gitignorefile with the following data:*
!.gitignore -
@nedbat@hachyderm.io Another option that'd often (but maybe not always) be preferable: create the directory when it's needed, e.g. during build.
@airtower love this.
Versioning the empty dirs is a bandaid that addresses the symptom, not the root cause!!
-
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...
-
R relay@relay.publicsquare.global shared this topic