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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:02:28  来源:igfitidea点击:

How to make .gitignore ignore compiled files with no extension?

gitgitignore

提问by Kurtosis

Possible Duplicate:
gitignore without binary files

可能的重复:
没有二进制文件的 gitignore

Edit: Dupe of gitignore without binary files

编辑:没有二进制文件gitignore 欺骗

When you compile, say, a Haskell file, (test.hs), using ghc --make test.hs, the result is test.hiand test. I only want to add and commit the source test.hs, while keeping test.hiand testout of the repository but in the same directory as the source file. testis the problem, how do I specify to .gitignore to ignore a compiled file with no extension?

例如,当您编译一个 Haskell 文件 ( test.hs) 时,使用ghc --make test.hs,结果是test.hitest。我只想添加和提交 source test.hs,同时保留test.hitest退出存储库但与源文件位于同一目录中。 test问题是,我如何指定 .gitignore 以忽略没有扩展名的编译文件?

回答by larsks

Just add the filename to your .gitignorefile. For example:

只需将文件名添加到您的.gitignore文件中。例如:

$ git ls-files --other --exclude-standard
test
$ echo test > .gitignore
$ git ls-files --other --exclude-standard
$

.gitignoredoesn't care about extensions. It just matches patterns.

.gitignore不关心扩展。它只是匹配模式。