.gitignore исключить папку с файлами, но включить подкаталог

У меня есть такие папки:

/foo/one.txt
/foo/bar/two.txt
/foo/other/three.txt

Я хочу исключить все в папке /foo/, кроме подпапки /foo/bar/. Как я могу это сделать?

С помощью этого .gitignore мне удалось исключить «другую» подпапку, но файл «one.txt» все еще включен.

/foo/*
!/foo/bar/

person exstral    schedule 02.09.2011    source источник
comment
То, что вы сделали, работает так, как вы хотели для меня.   -  person CB Bailey    schedule 02.09.2011


Ответы (2)



Как сказал Чарльз Бейли в разделе комментариев, ваш код работает:

$ cat .gitignore 
/foo/*
!/foo/bar/

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .gitignore
#   foo/
nothing added to commit but untracked files present (use "git add" to track)
$ git add foo/ -n
add 'foo/bar/two.txt'
$ 
person Umang    schedule 02.09.2011