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.

Open in generator Open with C++, VisualStudioCode, Linux, Vim

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

PatternWhat it ignores and why
*.o*.obj*.ko*.elf*.dObject 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*.pchPrecompiled 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.**.dylibLibrariesStatic 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*.hexExecutablesLink output and HEX images for microcontrollers. a.out is also caught by *.out.
*.dSYM/*.su*.idb*.pdb*.dwoDebug informationmacOS symbol bundles, GCC -fstack-usage output (.su), MSVC debug databases and split DWARF (.dwo).
*.mod**.cmd.tmp_versions/modules.orderModule.symversMkfile.olddkms.confLinux kernel module buildsFiles the kernel build system (kbuild) leaves when building modules. Unless you develop drivers, you will rarely encounter them.
*.ilk*.map*.expLinker by-productsMSVC incremental link files, linker maps and export files.

Practical notes

Original template

C.gitignore36 rules
# 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

Often used together

More template explanations