目前,我.gitignore
中有以下内容:
...
sites/default/files/*
!sites/default/files/Library/bannerpt2.jpg
...
我想要完成的是sites/default/files/
除sites/default/files/Library/bannerpt2.jpg
之外我不想要任何{{1}}
答案 0 :(得分:4)
不幸的是,您需要手动包含路径中的所有子目录。这应该有效:
...
sites/default/files/*
!sites/default/files/Library/
sites/default/files/Library/*
!sites/default/files/Library/bannerpt2.jpg
...
答案 1 :(得分:3)
您可以使用git add -f file
样本互动:
$ 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")