.gitignore for C++
22 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-06-21 20:08:47 UTC
# Technologies: C++
### C++ ###
*.d
*.slo
*.lo
# Object file
*.o
# Object file
*.obj
*.gch
*.pch
*.ilk
# Program debug database
*.pdb
# Shared object
*.so
# macOS dynamic library
*.dylib
# Dynamic link library
*.dll
*.mod
*.smod
*.lai
*.la
# Static library
*.a
# Library file
*.lib
# Windows executable
*.exe
# Compiler output
*.out
# Application bundle
*.app
*.dwo
What these C++ rules actually ignore
Every pattern below, and why it belongs in your .gitignore.
Prerequisites
| Pattern | What it ignores |
|---|---|
*.d |
Prerequisites |
Compiled Object files
| Pattern | What it ignores |
|---|---|
*.slo |
Compiled Object files |
*.lo |
Compiled Object files |
*.o |
Object file |
*.obj |
Object file |
Precompiled Headers
| Pattern | What it ignores |
|---|---|
*.gch |
Precompiled Headers |
*.pch |
Precompiled Headers |
Linker files
| Pattern | What it ignores |
|---|---|
*.ilk |
Linker files |
Debugger Files
| Pattern | What it ignores |
|---|---|
*.pdb |
Program debug database |
Compiled Dynamic libraries
| Pattern | What it ignores |
|---|---|
*.so |
Shared object |
*.dylib |
macOS dynamic library |
*.dll |
Dynamic link library |
Fortran module files
| Pattern | What it ignores |
|---|---|
*.mod |
Fortran module files |
*.smod |
Fortran module files |
Compiled Static libraries
| Pattern | What it ignores |
|---|---|
*.lai |
Compiled Static libraries |
*.la |
Compiled Static libraries |
*.a |
Static library |
*.lib |
Library file |
Executables
| Pattern | What it ignores |
|---|---|
*.exe |
Windows executable |
*.out |
Compiler output |
*.app |
Application bundle |
*.dwo |
debug information files |
How to use this .gitignore for C++
- Copy the C++ rules above, or download the file directly.
- Create a file named .gitignore at the root of your Git repository and paste the rules into it.
- If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
- Commit the .gitignore so everyone on the team shares the same rules.