.gitignore for ROS2

17 ignore rules for ROS2, ready to copy into your repository.

Gitignore patterns for ROS2

The complete .gitignore for ROS2

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

### ROS2 ###
# Build output directory
build/
install/
log/
COLCON_IGNORE
AMENT_IGNORE
*.dox
*.wikidoc
# Eclipse project file
.project
# Eclipse C/C++ project
.cproject
# CMake user settings
CMakeLists.txt.user
srv/_*.py
*.pcd
*.pyc
qtcreator-*
# User-specific settings
*.user
# Emacs backup files
*~
# *
.

What these ROS2 rules actually ignore

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

General

Pattern What it ignores
build/ Build output directory
install/ General
log/ General

Colcon custom files

Pattern What it ignores
COLCON_IGNORE Colcon custom files
AMENT_IGNORE Colcon custom files

Ignore generated docs

Pattern What it ignores
*.dox Ignore generated docs
*.wikidoc Ignore generated docs
.project Eclipse project file
.cproject Eclipse C/C++ project
CMakeLists.txt.user CMake user settings
srv/_*.py Ignore generated docs
*.pcd Ignore generated docs
*.pyc Ignore generated docs
qtcreator-* Ignore generated docs
*.user User-specific settings
*~ Emacs backup files

Emacs

Pattern What it ignores
. *

How to use this .gitignore for ROS2

  1. Copy the ROS2 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 Other .gitignore templates

See every Other template