这是我的.gitignore:
This is my .gitignore:
#ignore all kind of files * #except php files !*.php我只想忽略除.php文件以外的所有类型的文件,但是有了.gitignore,我也忽略了文件夹...
All I want is to ignore all kind of files except the .php ones, but with this .gitignore I'm also ignoring folders...
是否有一种方法可以告诉git接受我的项目文件夹结构,同时仅跟踪.php文件?
Is there a way to tell git to accept my project folder structure while keeping the track only of the .php files?
似乎现在我无法将文件夹添加到我的仓库中了:
It seems like now I can't add folders to my repo:
vivo@vivoPC:~/workspace/motor$ git add my_folder/ The following paths are ignored by one of your .gitignore files: my_folder Use -f if you really want to add them. fatal: no files added推荐答案
这很简单,只需在.gitignore
#ignore all kind of files * #except php files !*.php !my_folder最后一行将特别注意my_folder,并且不会忽略其中的任何php文件;但是由于*的第一个模式,其他文件夹中的文件仍将被忽略.
The last line will take special care of my_folder, and will not ignore any php files within it; but files within other folders will still be ignored because of the first pattern of *.
编辑
我想我误解了你的问题.如果要忽略除.php文件以外的所有文件,可以使用
I think I misread your question. If you want to ignore all files except .php files, you can use
#ignore all kind of files *.* #except php files !*.php这不会忽略任何没有扩展名的文件(例如:如果您具有README而不是README.txt),并且将忽略名称中带有.的任何文件夹(例如:目录名为module.1).
This will not ignore any file which doesn't have an extension (example: if you have README and not README.txt ), and will ignore any folder with a . in its name (example: directory named module.1).
FWIW, git无法跟踪目录,因此无法为目录和文件指定忽略规则
FWIW, git doesn't track directories, and hence there is no way to specify ignore rules for directory vs file
更多推荐
git忽略除一个扩展名和文件夹结构以外的所有文件
发布评论