Let's assume I have a dir structure like so:
app/
uploads/
.gitkeep
images/
.gitkeep
videos/
.gitkeep
docs/
.gitkeep
I want to keep the dir structure but not include the files within (except .gitkeep
obviously). The docs say:
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
So, I would expect this to do the trick:
/app/uploads/**
!/app/uploads/**/.gitkeep
This isn't working however. None of the subdirectories are being added.
gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
Repository exclude - For local files that do not need to be shared, you just add the file pattern or directory to the file . git/info/exclude .
gitignore is located in the root directory of your repo. / will ignore directories with the name.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
The structure that I'm used, looks like this:
app/
.gitignore
uploads/
images/
.gitkeep
videos/
.gitkeep
docs/
.gitkeep
Content of my app/.gitignore file:
uploads/** # Ignore everything in 'uploads' folder
!uploads/**/ # exclude subdirectories
!.gitkeep # and .gitkeep files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With