Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore file for C projects

Tags:

git

c

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.

No suggestion can be too obvious -- I'm a total noob. Thanks!

like image 743
dylanfm Avatar asked May 11 '09 03:05

dylanfm


People also ask

How do I ignore a file in Git?

Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

Where do I put Git ignore file?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .


3 Answers

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):

  • object files (.o, o.obj)
  • libraries (.lib)
  • DLLs, shared objects (.so, .dll)
  • Executables (.exe, a.out ?)

GIT ignore files are something I tend to do iteratively. "Hey, I don't need those things in my repo" ...

Edit: re dmckee's comment

Yep, you definately want to be ignoring swap files, temp files etc. I have the following as a baseline for my .gitignore:

  • *.swp
  • .~
  • thumbs.db
like image 59
RedBlueThing Avatar answered Oct 10 '22 04:10

RedBlueThing


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

build/

And you're done.

like image 22
Flame Avatar answered Oct 10 '22 04:10

Flame


I use this in my .gitignore But I am building for micro-controllers, so I don't know if it helps you much.

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.

#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
like image 42
SpiRail Avatar answered Oct 10 '22 03:10

SpiRail