Please note the following structure:
/assets --> this dir shouldn't be ignored. but SOME OF their contents SHOULD.;
ignoredfile.jpg --> should be ignored.
ignoredfile2.gif --> --> should be ignored.
/blog --> this dir shouldn't be ignored. but SOME OF their contents SHOULD.;
/images --> this dir shouldn't be ignored. but ALL their contents SHOULD.;
Inside /assets folder I have a gitignore file with:
# Ignore everything in this directory
*
# Except this file
!.gitignore
!/images
!/resize
!/blog
Inside ‘/assets/blog’ I have another .gitignore.
# Ignore everything in this directory
*
# Except those files
!.gitignore
!/images
ISSUE
When I push to the remote server, git DO pushed the /blog directory but NOT the /blog/images one. Why ?
How can I solve this ?
Just remove it from
.gitignoreand re-add it using the usualgit add -A <directory-name>, and you should be fine..Beware of merges that might remove the directory again, but if you are merging everything correctly you should be fine.
Update
You cannot commit empty directories in git; a common way to do that is to put an empty “placeholder” file inside it, just to say you want it to stay there.
For example, put an empty hidden file named
.keepinto the/imagesdirectory and change the.gitignorelike this:now, you add/commit the
.keepfile and you should be fine..Alternate solution
Place a
.gitignoreinside/images, with this content: