git 如何让 .gitignore 忽略没有扩展名的编译文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7615983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make .gitignore ignore compiled files with no extension?
提问by Kurtosis
Possible Duplicate:
gitignore without binary files
可能的重复:
没有二进制文件的 gitignore
Edit: Dupe of gitignore without binary files
When you compile, say, a Haskell file, (test.hs
), using ghc --make test.hs
, the result is test.hi
and test
. I only want to add and commit the source test.hs
, while keeping test.hi
and test
out of the repository but in the same directory as the source file. test
is the problem, how do I specify to .gitignore to ignore a compiled file with no extension?
例如,当您编译一个 Haskell 文件 ( test.hs
) 时,使用ghc --make test.hs
,结果是test.hi
和test
。我只想添加和提交 source test.hs
,同时保留test.hi
和test
退出存储库但与源文件位于同一目录中。 test
问题是,我如何指定 .gitignore 以忽略没有扩展名的编译文件?
回答by larsks
Just add the filename to your .gitignore
file. For example:
只需将文件名添加到您的.gitignore
文件中。例如:
$ git ls-files --other --exclude-standard
test
$ echo test > .gitignore
$ git ls-files --other --exclude-standard
$
.gitignore
doesn't care about extensions. It just matches patterns.
.gitignore
不关心扩展。它只是匹配模式。