.gitignore for C

C compiled object files, static and shared libraries, and build artifacts.

Quick presets

Selected (1)
C
Your selections never leave your browser. Generation happens entirely client-side.
Raw

24 patterns · 269 B

# Generated by DevZone Tools — https://devzone.tools/tools/gitignore-generator
# Templates: C
# 2026-04-20

# ---- C ----
# C
*.d
*.o
*.ko
*.obj
*.elf
*.ilk
*.map
*.exp
*.gch
*.pch
*.lib
*.a
*.la
*.lo
*.dll
*.so
*.so.*
*.dylib
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

What this template ignores

Ignores compiled object files (.o, .obj), static libraries (.a, .lib), shared libraries (.so, .dll, .dylib), compiled executables, and precompiled headers.

Common additions

  • +build/ — CMake/Makefile build directory
  • +*.d — dependency files generated by gcc

Commonly paired with

Frequently asked questions

Do I need to commit .gitignore?
Yes — .gitignore should be committed to the repository so all collaborators benefit from the same ignore rules.
How do I add custom patterns?
Open your .gitignore file and add the pattern on a new line. Use # for comments, * for wildcards, / to match directories, and ! to un-ignore a previously ignored path.
How do I ignore a file that is already tracked?
Adding a file to .gitignore does not remove it from tracking if it was previously committed. Run: git rm --cached <file> to stop tracking it without deleting the file locally.
What are .d files in C projects?
.d files are dependency files generated by gcc/clang (-MMD flag). They list header file dependencies for incremental builds and should not be committed.

Looking for something else? Browse all templates →