[英]Git: How to ignore files on Windows?
I create .gitignore in folder with my repository near .git 我在.git附近的资料夹中建立.gitignore
project
--.git
--.gitignore
--Source
----tmp
----scr
But git doesn t see it, wouldn
t ignore files in .gitignore 但是git没有
t see it, wouldn
忽略.gitignore中的文件
My .gitignore file: 我的.gitignore文件:
*.tmp
*~
*.pdb
*.user
*.suo
Sources/tmp
What`s wrong? 怎么了
Up: I created new repositiry, add .gitignore before init commit - it work! 上:我创建了新的存储库,在进行init commit之前添加.gitignore-它起作用了! But if I add in old repository it doesn`t...
但是,如果我添加旧存储库,则不会...
The problem is that you're specifying glob syntax when the default syntax for git is regex. 问题是,当git的默认语法为regex时,您正在指定glob语法。
Try this instead: 尝试以下方法:
.*\.tmp
.*~
.*\.pdb
.*\.user
.*\.suo
Sources\/tmp
What you have should work, though your directory listing has Source/
while your .gitignore
has Sources/
. 尽管目录列表中包含
Source/
而.gitignore
包含Sources/
,您所拥有的应该起作用。
The one thing that springs to mind is that the line endings might not be what git is expecting. 我想到的一件事是,行尾可能不是git期望的。
Also, as tmp is a directory, usually a trailing '/' is used: 另外,由于tmp是目录,因此通常使用结尾的“ /”:
Source/tmp/
来源/ tmp /
Finally, you can also create a .gitignore in Source/
with the line: 最后,您还可以使用以下
Source/
行在Source/
创建一个.gitignore:
tmp/ instead of having it in the top directory.
tmp /而不是放在顶层目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.