Git 忽略 C 项目的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/846639/
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
Git ignore file for C projects
提问by dylanfm
I've just started to learn C (using Thinking In C) and I'm wondering about what files I should be ignoring in a C project's git repository.
我刚刚开始学习 C(使用Thinking In C),我想知道我应该在 C 项目的 git 存储库中忽略哪些文件。
No suggestion can be too obvious -- I'm a total noob. Thanks!
没有任何建议可以太明显 - 我是一个完全的菜鸟。谢谢!
采纳答案by RedBlueThing
I guess there will be a few generated files that you don't wan't to be sticking in your repo (assuming your build output dir is in your git heirachy):
我想会有一些生成的文件你不想粘在你的仓库中(假设你的构建输出目录在你的 git heirachy 中):
- object files (.o, o.obj)
- libraries (.lib)
- DLLs, shared objects (.so, .dll)
- Executables (.exe, a.out ?)
- 目标文件 (.o, o.obj)
- 库 (.lib)
- DLL、共享对象(.so、.dll)
- 可执行文件(.exe,a.out ?)
GIT ignore files are something I tend to do iteratively. "Hey, I don't need those things in my repo" ...
GIT 忽略文件是我倾向于反复执行的操作。“嘿,我的仓库中不需要那些东西”......
Edit: re dmckee's comment
编辑:重新 dmckee 的评论
Yep, you definately want to be ignoring swap files, temp files etc. I have the following as a baseline for my .gitignore:
是的,您肯定希望忽略交换文件、临时文件等。我将以下内容作为我的 .gitignore 的基线:
- *.swp
- .~
- thumbs.db
- *.swp
- . ~
- 大拇指数据库
回答by Flame
You can also setup your build to happen in a subdirectory say build
and then you can ignore the whole thing inside .gitignore
你也可以设置你的构建发生在一个子目录中build
,然后你可以忽略里面的整个事情.gitignore
build/
建造/
And you're done.
你已经完成了。
回答by SpiRail
I use this in my .gitignore But I am building for micro-controllers, so I don't know if it helps you much.
我在我的 .gitignore 中使用它但是我正在为微控制器构建,所以我不知道它是否对你有很大帮助。
The easiest way to know, is just do a make clean, then add all your files, then do a make all and see what extra stuff appears.
最简单的了解方法是执行 make clean,然后添加所有文件,然后执行 make all 并查看会出现哪些额外内容。
#Some of these are related to eclipse. So i keep them out of my repo
.cproject
.dep/
.project
.settings/
#files being edited
*~
# make and build files
*.lst
*.o
*.eep
*.lss
*.map
*.sym
# I keep these, since I prefer having the reference of the final build
# *.elf
# *.hex