How to Keep Apache Airflow® Files Out of Git with .gitignore
When AIRFLOW_HOME is your project folder, Apache Airflow® writes its own files next to your code: a settings file with generated secrets, a database, logs and a file with the admin password. None of them belong in Git, and two of them are secrets. A .gitignore keeps them out before your first commit. This guide writes one on Airflow 3.4.0 and checks that it works.
Syntax
<file or folder name>
<folder>/
<pattern with *>
| Line | What it ignores |
|---|---|
airflow.cfg | A file with this name, in any folder |
logs/ | A folder with this name, and everything in it |
airflow.db-* | Every name that starts with airflow.db- |
# ... | Nothing: a comment |
Git's documentation for .gitignore calls each line a pattern, and says a pattern ending in a slash only matches a folder.
Prerequisites
- Git. Check with
git --version.
Step 1: See What Airflow Left in the Project
This project ran airflow standalone once, with AIRFLOW_HOME set to the project folder. It has one Dag in dags. Make it a Git repository and look at the status:
git init -b main
git status --short
Initialized empty Git repository in /Users/you/source/airflow-gitignore-demo/.git/
?? airflow.cfg
?? airflow.db
?? dags/
?? logs/
?? simple_auth_manager_passwords.json.generated

?? means untracked: a git add . would add every one of them. Only dags/ is yours:
| Name | What it is | In Git? |
|---|---|---|
airflow.cfg | Every setting, plus a generated fernet_key, [api] secret_key and [api_auth] jwt_secret. Airflow creates it readable only by you | No: it holds secrets |
airflow.db | The SQLite metadata database: runs, users, state | No |
logs/ | Task and component logs | No |
simple_auth_manager_passwords.json.generated | The admin password | No: it's a password |
dags/ | Your Dag files | Yes |
The .venv folder isn't listed at all: uv puts a .gitignore of its own inside it, containing *, so Git already ignores it.
Step 2: Write the .gitignore
Create a file named .gitignore in the project folder:
# Python
.venv/
__pycache__/
# Files Airflow creates in AIRFLOW_HOME (this folder). airflow.cfg holds generated
# secrets, so it never goes into Git.
airflow.cfg
airflow.db
airflow.db-*
logs/
simple_auth_manager_passwords.json.generated

.venv/ is listed anyway, so it stays ignored if the environment was made by a tool that doesn't add its own .gitignore. __pycache__/ catches Python's compiled files. airflow.db-* catches the extra files SQLite keeps next to the database while Airflow runs.
Step 3: Check It
git status --short
?? .gitignore
?? dags/
git status --short --ignored
?? .gitignore
?? dags/
!! .venv/
!! airflow.cfg
!! airflow.db
!! logs/
!! simple_auth_manager_passwords.json.generated

The first command now lists only .gitignore and dags/: that's all git add . would take. The second adds the ignored names, marked !!, and every Airflow file is among them.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Committing before writing .gitignore | airflow.cfg and the password are in the history | Write .gitignore first; if it's too late, change the secrets |
Ignoring dags/ | Your Dags aren't saved | Ignore only what Airflow generates |
Adding .gitignore after git add . | Files already staged stay staged | Unstage them with git rm --cached <file> |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
A file still shows ?? | The line doesn't match it, or has a typo | Compare the name exactly |
An ignored file is in git status as changed | It was committed before you ignored it | git rm --cached <file>, then commit |
FAQ
Should airflow.cfg ever be committed?
Not this one: it contains the secrets Airflow generated for you. To share settings, use environment variables or a template without secrets.
Is the password file the same as the UI login?
Yes: it holds the generated password for the admin user.
Conclusion
After one airflow standalone, git status --short listed four Airflow files next to dags/. Seven patterns in .gitignore left only .gitignore and dags/ to commit, and git status --short --ignored confirmed that airflow.cfg, airflow.db, logs/, the password file and .venv/ are ignored.
Additional Resources
- gitignore — how patterns match.
- git status — the short format and
--ignored.
Apache®, Apache Airflow and Airflow® are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.
