github/gitignore · C.gitignore
C .gitignore Template Explained
Why C.gitignore ignores object files, static and shared libraries, executables, debug info and Linux kernel module build files.
C.gitignore blocks the intermediate files and output produced by compilers and linkers based on their extensions. It includes extensions from several platforms so it works with gcc, clang or MSVC.
It does not deal with build-system files such as those from Make or CMake. If you use CMake, refer to the CMake template or the C++ template, which contains CMake rules.
Rules explained
| Pattern | What it ignores and why |
|---|---|
*.o*.obj*.ko*.elf*.d | Object and dependency filesCompilation results for each source file (.o, .obj), kernel modules (.ko), ELF binaries, and header dependency lists generated by the compiler (.d). |
*.gch*.pch | Precompiled headersPrecompiled headers from GCC and MSVC. They are tied to the compiler version and options and cannot be used in other environments. |
*.lib*.a*.la*.lo*.dll*.so*.so.**.dylib | LibrariesStatic libraries (.a, .lib), libtool files (.la, .lo) and shared libraries. *.so.* catches versioned names such as libfoo.so.1.2. |
*.exe*.out*.app*.i*86*.x86_64*.hex | ExecutablesLink output and HEX images for microcontrollers. a.out is also caught by *.out. |
*.dSYM/*.su*.idb*.pdb*.dwo | Debug informationmacOS symbol bundles, GCC -fstack-usage output (.su), MSVC debug databases and split DWARF (.dwo). |
*.mod**.cmd.tmp_versions/modules.orderModule.symversMkfile.olddkms.conf | Linux kernel module buildsFiles the kernel build system (kbuild) leaves when building modules. Unless you develop drivers, you will rarely encounter them. |
*.ilk*.map*.exp | Linker by-productsMSVC incremental link files, linker maps and export files. |
Practical notes
- A build directory (
build/) is not in this template. If you use out-of-source builds, add/build/yourself. *.mod*matches every extension starting with.mod, so if you have.modfiles for other purposes (for example, data files), add an exception.- If a firmware repository needs to keep
.hexfiles for release, re-include only a specific path, such as!release/*.hex.
Original template
C.gitignore
# Prerequisites*.d# Object files*.o*.ko*.obj*.elf# Linker output*.ilk*.map*.exp# Precompiled Headers*.gch*.pch# Libraries*.lib*.a*.la*.lo# Shared objects (inc. Windows DLLs)*.dll*.so*.so.**.dylib# Executables*.exe*.out*.app*.i*86*.x86_64*.hex# Debug files*.dSYM/*.su*.idb*.pdb# Kernel Module Compile Results*.mod**.cmd.tmp_versions/modules.orderModule.symversMkfile.olddkms.conf# debug information files*.dwo
Templates from github/gitignore/C.gitignore @356fd7b (2026-09-11) · CC0-1.0