directory - How to track directories but not their files with Git? -
i've started using git , having trouble 1 thing. how can track directories without tracking contents?
for example site i'm working on allows uploads. want track uploads directory created when branching, etc. not files within (test files whilst in develop branch or real files in master).
in .gitignore have following:
uploads/*.*
have tried (which ignores whole directory):
uploads/
this directory may contain sub directories (uploads/thumbs/ uploads/videos/) able track these not files.
is possible git? i've searched everywhere without finding answer.
git doesn't track directories, tracks files, acheive need track @ least 1 file. assuming .gitignore
file looks this:
upload/*
you can this:
$ touch upload/.placeholder $ git add -f upload/.placeholder
if forget -f
you'll see:
$ git add upload/.placeholder following paths ignored 1 of .gitignore files: upload use -f if want add them. fatal: no files added
then when git status
you'll see:
# on branch master # # initial commit # # changes committed: # (use "git rm --cached ..." unstage) # # new file: upload/.placeholder #
obviously can do:
$ touch upload/images/.placeholder $ git add -f upload/images/.placeholder
Comments
Post a Comment