这是我的.gitignore:
#ignore all kind of files
*
#except php files
!*.php
Run Code Online (Sandbox Code Playgroud)
我想要的只是忽略除了.php之外的所有文件,但是这个.gitignore我也忽略了文件夹...
有没有办法告诉git接受我的项目文件夹结构,同时只保留.php文件的轨道?
好像现在我无法在我的仓库中添加文件夹:
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
Run Code Online (Sandbox Code Playgroud)
mu *_*u 無 28
这很简单,只需添加另一个项目!my_folder
在.gitignore
#ignore all kind of files
*
#except php files
!*.php
!my_folder
Run Code Online (Sandbox Code Playgroud)
最后一行将特别注意my_folder
,并且不会忽略其中的任何php文件; 但由于第一种模式,其他文件夹中的文件仍将被忽略*
.
编辑
我想我误读了你的问题.如果要忽略文件以外的所有.php
文件,可以使用
#ignore all kind of files
*.*
#except php files
!*.php
Run Code Online (Sandbox Code Playgroud)
这不会忽略任何没有扩展名的文件(例如:如果你有README
没有README.txt
),并且会忽略.
名称中包含a的任何文件夹(例如:名为directory module.1
).
FWIW,git不跟踪目录,因此无法为目录vs文件指定忽略规则
我有一个类似的问题。我想将其列入白名单*.c
,但是接受的答案对我而言不起作用,因为我的文件中不包含“。”。
因此,对于那些想要处理的人:
# ignore everything
*
# but don't ignore files ending with slash = directories
!*/
# and don't ignore files ending with ".php"
!*.php
Run Code Online (Sandbox Code Playgroud)
这对我有用(不包括除 .gitkeep 文件之外的所有 imgs 文件夹内容)
/imgs/**/*.*
!/imgs/**/.gitkeep
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11695 次 |
最近记录: |