有没有办法从 makefile 生成 gitignore?
我有很多文件,例如 JavaScript、HTML,甚至是自动生成的 C 和 C 头文件 (.h),因此它们会出现在 makefile 中,如
myfile.js: myfile.js.tmpl
等。我希望版本忽略所有这些目标文件控制系统。我正在使用 git,但这个问题不是特定于 git 的。是否有实用程序或技巧可以从 makefile 生成忽略文件(如 .gitignore
)?
(如果没有这样的工具,我可以编写一个脚本来创建一个,但在这样做之前,我只是检查我没有错过一些明显的工具或方法。)
I have a lot of files such as JavaScript, HTML, and even C and C header (.h) files which are automatically generated, so they appear in the makefile like
myfile.js: myfile.js.tmpl
etc. I want all of these target files to be ignored by the version control system. I am using git but this question is not git-specific. Is there a utility or a trick which exists to make the ignore file (like .gitignore
) from a makefile?
(If there isn't such a facility, I can make a script to create one, but before I do that I am just checking I haven't missed some obvious tool or method.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是从干净的签出开始,进行构建,然后运行 git status 来找出哪些文件未被跟踪。将这些文件(或合适的模式)添加到您的
.gitignore
文件中。Makefile 可能非常复杂,以至于了解它们的作用的唯一方法可能就是实际运行它们。
One way to do this would be to start with a clean checkout, do a build, then run a
git status
to find out which files are untracked. Add those files (or suitable patterns) to your.gitignore
file.Makefiles can be so complex that the only way to find out what they do might be to actually run them.