.gitignore for CMake

12 ignore rules for CMake, ready to copy into your repository.

Cross-platform build system generator

The complete .gitignore for CMake

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-08-05 01:29:18 UTC
# Technologies: CMake

### CMake ###
# CMake user settings
CMakeLists.txt.user
# CMake cache
CMakeCache.txt
# CMake generated files
CMakeFiles
# CMake scripts
CMakeScripts
# CMake testing directory
Testing
# CMake install script
cmake_install.cmake
# CMake install manifest
install_manifest.txt
# Compilation database
compile_commands.json
# CTest configuration
CTestTestfile.cmake
# CMake dependencies
_deps
CMakeUserPresets.json
# Generated makefile
Makefile

What these CMake rules actually ignore

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

General

Pattern What it ignores
CMakeLists.txt.user CMake user settings
CMakeCache.txt CMake cache
CMakeFiles CMake generated files
CMakeScripts CMake scripts
Testing CMake testing directory
cmake_install.cmake CMake install script
install_manifest.txt CMake install manifest
compile_commands.json Compilation database
CTestTestfile.cmake CTest configuration
_deps CMake dependencies
CMakeUserPresets.json General
Makefile Generated makefile

How to use this .gitignore for CMake

  1. Copy the CMake 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 Build Tool .gitignore templates

See every Build Tool template