Reputation: 5325
Currently I have the following in my .gitignore
:
...
sites/default/files/*
!sites/default/files/Library/bannerpt2.jpg
...
What I'm trying to accomplish is I don't want any of sites/default/files/
EXCEPT for sites/default/files/Library/bannerpt2.jpg
.
Upvotes: 3
Views: 225
Reputation: 1466
You can add the file in the excluded folder using git add -f file
Sample Interaction:
$ git init
Initialized empty Git repository in /Users/killerx/temp/.git/
$ echo "*" > .gitignore
$ touch a.txt
$ git add a.txt
The following paths are ignored by one of your .gitignore files:
a.txt
Use -f if you really want to add them.
fatal: no files added
$ git add -f a.txt
$ git commit -m "t"
[master (root-commit) db22f19] t
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a.txt
$ echo "a" > a.txt
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: a.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Upvotes: 3
Reputation: 136984
You need to manually include all subdirectories in the path, unfortunately. This should work:
...
sites/default/files/*
!sites/default/files/Library/
sites/default/files/Library/*
!sites/default/files/Library/bannerpt2.jpg
...
Upvotes: 5