A .gitignore file tells Git which files or directories to leave out of commits. Keep sensitive configuration such as .streamlit/secrets.toml locally while sharing the application code. section 5.4.2
Use .gitignore as part of a safe deployment workflow:
- Create an empty .gitignore file in the repository root if one does not exist. section 5.4.2
- Add .streamlit/ to exclude secrets.toml and other files in that directory. section 5.4.2
- If Git already tracks the directory, remove it from the index with git rm -r --cached .streamlit/. section 5.4.2
- For Elastic Beanstalk deployments, also ignore .ebextensions/ and .elasticbeanstalk/ when they contain deployment configuration or generated settings. section 12.3.5
Protecting Streamlit secrets
A repository can contain .streamlit/secrets.toml locally while its root .gitignore contains .streamlit/. Running git add or git commit then leaves the secrets directory out of the commit. section 5.4.2
Root of your Git repo ├── .streamlit (folder) │ └── secrets.toml ├── .gitignore ├── requirements.txt ├── jokes.py ├── task.py └── todo_list.py
Use the repository layout to see where .gitignore belongs relative to .streamlit/secrets.toml and the application files. section 5.4.2

