.gitignore pour Python

95 règles d’exclusion pour Python, prêtes à copier dans votre dépôt.

Le langage de programmation Python

Le .gitignore complet pour Python

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-09-17 17:00:39 UTC
# Technologies: Python

### Python ###
# Python bytecode cache directory
__pycache__/
*.py[codz]
# Python/Jython class files
*$py.class
# IPython default profile
profile_default/
# Shared object
*.so
# IPython configuration
ipython_config.py
# Python version marker
.Python
# Build output directory
build/
# Python development eggs
develop-eggs/
# Distribution directory
dist/
# Downloaded files
downloads/
# Python egg packages
eggs/
# Python eggs directory
.eggs/
# Library directory
lib/
# 64-bit library directory
lib64/
# Buildout parts
parts/
# Python source distribution
sdist/
var/
# Python wheel packages
wheels/
# Shared Python wheels
share/python-wheels/
# Python package metadata
*.egg-info/
# Buildout installed config
.installed.cfg
# Python egg package
*.egg
# Python manifest file
MANIFEST
# Manifest files
*.manifest
# PyInstaller spec file
*.spec
# pip installation log
pip-log.txt
# pip marker file
pip-delete-this-directory.txt
# Coverage HTML report
htmlcov/
# tox test environments
.tox/
# nox test environments
.nox/
# Coverage data file
.coverage
# Coverage data files
.coverage.*
# Cache directory
.cache
# Nose test results
nosetests.xml
# Coverage XML report
coverage.xml
# Coverage annotated source
*.cover
*.py.cover
# LCOV coverage data
*.lcov
# Hypothesis test data
.hypothesis/
# pytest cache directory
.pytest_cache/
# Coverage reports
cover/
# Compiled message catalogs
*.mo
# Message catalog template
*.pot
# Log file
*.log
# Local Django settings
local_settings.py
# SQLite database
db.sqlite3
# SQLite journal
db.sqlite3-journal
# Flask instance folder
instance/
# Flask-Assets cache
.webassets-cache
# Scrapy cache
.scrapy
# Sphinx build output
docs/_build/
# PyBuilder directory
.pybuilder/
# Maven build directory
target/
# Jupyter notebook checkpoints
.ipynb_checkpoints
.pdm-python
.pdm-build/
.pixi/*
# PEP 582 packages
__pypackages__/
!.pixi/config.toml
# Celery beat PID file
celerybeat.pid
# Sage compiled files
*.sage.py
celerybeat-schedule*
# Environment variables
.env
*.rdb
.envrc
*.aof
# Python virtual environment
.venv
# Process ID file
*.pid
# Virtual environment directory
env/
mnesia/
# Virtual environment directory
venv/
rabbitmq/
# Environment backup
env.bak/
rabbitmq-data/
activemq-data/
# Virtual env backup
venv.bak/
# Spyder project
.spyderproject
# Spyder project settings
.spyproject
# Python rope refactoring
.ropeproject
/site
# mypy type checker cache
.mypy_cache/
# mypy daemon config
.dmypy.json
# mypy daemon config
dmypy.json
# Pyre type checker
.pyre/
# pytype static analyzer
.pytype/
# Cython debug symbols
cython_debug/
.abstra/
.ruff_cache/
.pypirc
marimo/_static/
marimo/_lsp/
__marimo__/
.streamlit/secrets.toml
tempCodeRunnerFile.py

Ce que ces règles Python ignorent vraiment

Chaque motif ci-dessous, et pourquoi il a sa place dans votre .gitignore.

Byte-compiled / optimized / DLL files

Motif Ce qu’il ignore
__pycache__/ Python bytecode cache directory
*.py[codz] Byte-compiled / optimized / DLL files
*$py.class Python/Jython class files

IPython

Motif Ce qu’il ignore
profile_default/ IPython default profile
ipython_config.py IPython configuration
.pdm-python pdm Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. https://pdm-project.org/en/latest/usage/project/#working-with-version-control pdm.lock pdm.toml
.pdm-build/ IPython
.pixi/* pixi Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. pixi.lock Pixi creates a virtual environment in the .pixi directory, just like venv module creates one in the .venv directory. It is recommended not to include this directory in version control.
!.pixi/config.toml IPython

C extensions

Motif Ce qu’il ignore
*.so Shared object

Distribution / packaging

Motif Ce qu’il ignore
.Python Python version marker
build/ Build output directory
develop-eggs/ Python development eggs
dist/ Distribution directory
downloads/ Downloaded files
eggs/ Python egg packages
.eggs/ Python eggs directory
lib/ Library directory
lib64/ 64-bit library directory
parts/ Buildout parts
sdist/ Python source distribution
var/ Distribution / packaging
wheels/ Python wheel packages
share/python-wheels/ Shared Python wheels
*.egg-info/ Python package metadata
.installed.cfg Buildout installed config
*.egg Python egg package
MANIFEST Python manifest file
*.manifest Manifest files
*.spec PyInstaller spec file

Installer logs

Motif Ce qu’il ignore
pip-log.txt pip installation log
pip-delete-this-directory.txt pip marker file

Unit test / coverage reports

Motif Ce qu’il ignore
htmlcov/ Coverage HTML report
.tox/ tox test environments
.nox/ nox test environments
.coverage Coverage data file
.coverage.* Coverage data files
.cache Cache directory
nosetests.xml Nose test results
coverage.xml Coverage XML report
*.cover Coverage annotated source
*.py.cover Unit test / coverage reports
.hypothesis/ Hypothesis test data
*.lcov LCOV coverage data
.pytest_cache/ pytest cache directory
cover/ Coverage reports

Translations

Motif Ce qu’il ignore
*.mo Compiled message catalogs
*.pot Message catalog template

Django stuff:

Motif Ce qu’il ignore
*.log Log file
local_settings.py Local Django settings
db.sqlite3 SQLite database
db.sqlite3-journal SQLite journal

Flask stuff:

Motif Ce qu’il ignore
instance/ Flask instance folder
.webassets-cache Flask-Assets cache

Scrapy stuff:

Motif Ce qu’il ignore
.scrapy Scrapy cache

Sphinx documentation

Motif Ce qu’il ignore
docs/_build/ Sphinx build output

PyBuilder

Motif Ce qu’il ignore
.pybuilder/ PyBuilder directory
target/ Maven build directory

Jupyter Notebook

Motif Ce qu’il ignore
.ipynb_checkpoints Jupyter notebook checkpoints

PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm

Motif Ce qu’il ignore
__pypackages__/ PEP 582 packages

Celery stuff

Motif Ce qu’il ignore
celerybeat.pid Celery beat PID file
celerybeat-schedule* Celery stuff

SageMath parsed files

Motif Ce qu’il ignore
*.sage.py Sage compiled files

Environments

Motif Ce qu’il ignore
.env Environment variables
.envrc Environments
.venv Python virtual environment
env/ Virtual environment directory
venv/ Virtual environment directory
env.bak/ Environment backup
venv.bak/ Virtual env backup

Redis

Motif Ce qu’il ignore
*.rdb Redis
*.aof Redis
*.pid Process ID file

RabbitMQ

Motif Ce qu’il ignore
mnesia/ RabbitMQ
rabbitmq/ RabbitMQ
rabbitmq-data/ RabbitMQ

ActiveMQ

Motif Ce qu’il ignore
activemq-data/ ActiveMQ

Spyder project settings

Motif Ce qu’il ignore
.spyderproject Spyder project
.spyproject Spyder project settings

Rope project settings

Motif Ce qu’il ignore
.ropeproject Python rope refactoring
/site mkdocs documentation
.mypy_cache/ mypy type checker cache
.dmypy.json mypy daemon config
dmypy.json mypy daemon config

Pyre type checker

Motif Ce qu’il ignore
.pyre/ Pyre type checker
.pytype/ pytype static analyzer

Cython debug symbols

Motif Ce qu’il ignore
cython_debug/ Cython debug symbols

Learn more at https://abstra.io/docs

Motif Ce qu’il ignore
.abstra/ Learn more at https://abstra.io/docs

Ruff stuff:

Motif Ce qu’il ignore
.ruff_cache/ Ruff stuff:

PyPI configuration file

Motif Ce qu’il ignore
.pypirc PyPI configuration file

Marimo

Motif Ce qu’il ignore
marimo/_static/ Marimo
marimo/_lsp/ Marimo
__marimo__/ Marimo

Streamlit

Motif Ce qu’il ignore
.streamlit/secrets.toml Streamlit

Temporary file for partial code execution

Motif Ce qu’il ignore
tempCodeRunnerFile.py Temporary file for partial code execution

Comment utiliser ce .gitignore pour Python

  1. Copiez les règles Python ci-dessus, ou téléchargez directement le fichier.
  2. Créez un fichier nommé .gitignore à la racine de votre dépôt Git et collez-y les règles.
  3. Si certains de ces fichiers sont déjà suivis, lancez git rm -r --cached . puis recommitez — Git n’applique les règles d’exclusion qu’aux fichiers non suivis.
  4. Commitez le .gitignore pour que toute l’équipe partage les mêmes règles.

Autres modèles .gitignore Language

Voir tous les modèles Language