Reputation: 258
Hey this does not work for me:
vendor/*
!vendor/predis/
vendor/predis/*
!vendor/predis/predis
vendor/predis/predis/*
!vendor/predis/predis/lib
vendor/predis/predis/lib/*
!vendor/predis/predis/lib/Predis
vendor/predis/predis/lib/Predis/*
!vendor/predis/predis/lib/Predis/Profile
vendor/predis/predis/lib/Predis/Profile/*
!vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php
Where did I make a mistake?
Upvotes: 2
Views: 182
Reputation: 5151
What is your actual state of the repository?
I believe that what you want to have is just:
vendor/*
Prior to creating .gitignore
file, just git add vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php
. It will now be tracked.
After you create .gitignore
file (or add the mentioned line to it) all untracked files in vendor
directory will be ignored.
[EDIT] (Correction after helpful comments, thanks!)
Please keep in mind that you cannot ignore a file that is already tracked. If you want to do that, you need execute command git update-index --assume-unchanged
against the files you want to ignore - but this change will be local to your repository, it will not be shared. For more details see How to ignore files only locally in git?.
Upvotes: 1
Reputation: 817
create .gitignore
with
vendor/*
then git add -f vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php
the -f
option will ignore the rules in .gitignore
, so the file will be tracked
Upvotes: 0