Git忽略C项目的文件

时间:2022-02-26 14:03:41

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!

没有任何建议可以太明显 - 我是一个完全的菜鸟。谢谢!

3 个解决方案

#1


15  

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)
  • 目标文件(.o,o.obj)
  • libraries (.lib)
  • 库(.lib)
  • DLLs, shared objects (.so, .dll)
  • DLL,共享对象(.so,.dll)
  • Executables (.exe, a.out ?)
  • 可执行文件(.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
  • * .SWP
  • .~
  • 。〜
  • thumbs.db
  • 的Thumbs.db

#2


15  

You can also setup your build to happen in a subdirectory say build and then you can ignore the whole thing inside .gitignore

您还可以将构建设置为在子目录中进行构建,然后您可以忽略.gitignore中的整个内容

build/

建立/

And you're done.

而且你已经完成了。

#3


2  

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

#1


15  

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)
  • 目标文件(.o,o.obj)
  • libraries (.lib)
  • 库(.lib)
  • DLLs, shared objects (.so, .dll)
  • DLL,共享对象(.so,.dll)
  • Executables (.exe, a.out ?)
  • 可执行文件(.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
  • * .SWP
  • .~
  • 。〜
  • thumbs.db
  • 的Thumbs.db

#2


15  

You can also setup your build to happen in a subdirectory say build and then you can ignore the whole thing inside .gitignore

您还可以将构建设置为在子目录中进行构建,然后您可以忽略.gitignore中的整个内容

build/

建立/

And you're done.

而且你已经完成了。

#3


2  

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