我正在尝试包含一些处于被忽略目录中的文件,但请参阅以下内容。我如何包含它们?谢谢
[Michael@devserver bidjunction]$ git add html/about-us.html
The following paths are ignored by one of your .gitignore files:
html/about-us.html
Use -f if you really want to add them.
fatal: no files added
[Michael@devserver bidjunction]$
我的.gitignore
文件
[Michael@devserver bidjunction]$ cat .gitignore
/html/
/ayb_cache/
/ayb_resources/
#Some cache files in the main application
/ayb_application/lib/plugins/tinymce_plugins/imageManager/cache/
/ayb_application/lib/plugins/tinymce_plugins/image_purchased/cache/
/ayb_application/lib/plugins_3rd/tinymce_4.0.6/plugins/image/cache/
# Temp files often created by editors
*.~
# Track some files in html directory
!/html/css/
!/html/images/
!/html/scripts/
!/html/about-us.html
!/html/corporate.php
!/html/index.html
!/html/muse_manifest.xml
!/html/terms-and-conditions.html
[Michael@devserver bidjunction]$
答案 0 :(得分:1)
Shawn Balestracci提到(the comments)“.gitignore
exclude folder but include specific subfolder”,其中说明了我在this answer中提到的内容:
如果排除该文件的父目录,则无法重新包含文件。 (
*
)
(*
:除非在git 2中满足某些条件。?,见下文)
如果您排除html/*
,则会排除内容,而不是文件夹本身,从而允许应用!xxx
规则。
请注意,要始终检查忽略特定文件的原因,您可以输入:
git check-ignore -v -- html/about-us.html
这会为您提供.gitignore
文件的确切行,这是git add
无效的原因。
请注意,使用git 2.9.x / 2.10(2016年中期?),如果排除该文件的父目录if there is no wildcard in the path re-included,则可能会重新包含文件。
Nguyễn Thái Ngọc Duy (pclouds
)正在尝试添加此功能:
在你的情况下,可行的(使用git 2.?+)将是:
/html
!/html/css
!/html/images
!/html/scripts
!/html/about-us.html
!/html/corporate.php
!/html/index.html
!/html/muse_manifest.xml
!/html/terms-and-conditions.html