.gitignore for C

36 ignore rules for C, ready to copy into your repository.

The C programming language

The complete .gitignore for C

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-08-05 01:31:22 UTC
# Technologies: C

### C ###
*.d
# Object file
*.o
*.ko
# Object file
*.obj
*.elf
*.gch
*.ilk
*.map
*.pch
*.exp
# Library file
*.lib
# Static library
*.a
*.la
*.lo
# Dynamic link library
*.dll
# Shared object
*.so
# Versioned shared object
*.so.*
# macOS dynamic library
*.dylib
# Windows executable
*.exe
# Compiler output
*.out
# Application bundle
*.app
# 32-bit x86 binary
*.i*86
# 64-bit x86 binary
*.x86_64
# Hex dump file
*.hex
# macOS debug symbols
*.dSYM/
# Stack usage file
*.su
# Intermediate debug file
*.idb
# Program debug database
*.pdb
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
*.dwo

What these C rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Prerequisites

Pattern What it ignores
*.d Prerequisites

Object files

Pattern What it ignores
*.o Object file
*.ko Object files
*.obj Object file
*.elf Object files

Precompiled Headers

Pattern What it ignores
*.gch Precompiled Headers
*.pch Precompiled Headers

Linker output

Pattern What it ignores
*.ilk Linker output
*.map Linker output
*.exp Linker output

Libraries

Pattern What it ignores
*.lib Library file
*.a Static library
*.la Libraries
*.lo Libraries

Shared objects (inc. Windows DLLs)

Pattern What it ignores
*.dll Dynamic link library
*.so Shared object
*.so.* Versioned shared object
*.dylib macOS dynamic library

Executables

Pattern What it ignores
*.exe Windows executable
*.out Compiler output
*.app Application bundle
*.i*86 32-bit x86 binary
*.x86_64 64-bit x86 binary
*.hex Hex dump file

Debug files

Pattern What it ignores
*.dSYM/ macOS debug symbols
*.su Stack usage file
*.idb Intermediate debug file
*.pdb Program debug database

Kernel Module Compile Results

Pattern What it ignores
*.mod* Kernel Module Compile Results
*.cmd Kernel Module Compile Results
.tmp_versions/ Kernel Module Compile Results
modules.order Kernel Module Compile Results
Module.symvers Kernel Module Compile Results
Mkfile.old Kernel Module Compile Results
dkms.conf Kernel Module Compile Results
*.dwo debug information files

How to use this .gitignore for C

  1. Copy the C rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Language .gitignore templates

See every Language template