Friday, May 6, 2011

Git ignore file for C projects

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!

From stackoverflow
  • 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
    dmckee : If you editor makes automatic backups (ala emacs' *~ files), you can probably do without those too.
    Jakub Narębski : Usually you put ignoring of generated files in version controlled and transferred `.gitignore` file (so everybody will have generated files ignored), but ignoring backup files and other types of files depending on your environment (backup files can be *~ or *.bak) in not transferred repository .git/info/exclude (or in core.excludesfile set in ~/.gitconfig).
  • 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.

0 comments:

Post a Comment