I am having a problem with gitignore in Laravel 5.3.
I have the following gitignore file. I used !
to exclude myfile.json.
node_modules/
public/storage
storage/*.key
/.idea
Homestead.json
Homestead.yaml
.env
SQL/
*.sql
mynotes.md
!storage/app/mydir/myfile.json
When I run git status --ignored
I get this outputs.
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
../.env
../SQL/
../app/.DS_Store
../bootstrap/cache/config.php
../bootstrap/cache/services.php
../mynotes.md
../node_modules/
uploads/.DS_Store
../storage/app/.DS_Store
../storage/app/mydir/
...
...
So myfile.json is ignored. How can I write a gitignore so that I can add/commit a file?
The rule to remember with gitignore:
It is not possible to re-include a file if a parent directory of that file is excluded.
So check which .gitignore
rule actually does ignore ../storage/app/mydir/
, because if it is a .gitignore
located (for instance) directly in /storage/app/
, it will have precedence.
git check-ignore -v -- ../storage/app/mydir/myfile.json
../
means your current .gitignore
is not in the right place: for a !storage/app/mydir/xxx
rule to apply, it should be in a .gitignore
file one folder up.
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