Reputation: 31
So I have /vendor in gitignore and want to exclude some files in subfolders but it won't work, they are still being ignored. Checked git documentation, some threads here and still no luck, any idea what I'm missing?
This is what I got:
vendor
!vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
!vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php
Upvotes: 1
Views: 95
Reputation: 76887
You can force add them once using git add -f
, and they will afterward remain tracked within the repo:
git add -f vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
git add -f vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php
As mentioned by Daniel in comment, as per the documentation,
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
This is also clear if you try to use check-ignore
on the file foe identifying which rule is ignoring the files:
Test $ mkdir -p vendor/laravel/framework/src/Illuminate/Auth/Passwords && touch vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
Test $ cat .gitignore
vendor
!vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
Test $ git check-ignore -v vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
.gitignore:1:vendor vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
Test $ git add vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
The following paths are ignored by one of your .gitignore files:
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
Use -f if you really want to add them.
Upvotes: 4