LoginSignup
2

More than 5 years have passed since last update.

git: Djangoでlocal_settings.pyを.gitignoreに入れておく理由

Last updated at Posted at 2017-01-13

Djangoでプロジェクトを入れていたら.gitignoreに以下を指定するように記載されていた。

venv_ryugakuotaku
__pycache__
staticfiles
local_settings.py
db.sqlite3
*.py[co]

ところでlocal_settings.pyを含める理由が何なのか疑問に思ったので調べてみることに。

結論から言うと「ローカルデータベース上でのコンフリクトを防ぐため」ではないかという結論に至りました。

詳しく言うと、djangoではローカルデータベースをlocal_settings.pyで管理しています。ローカルでデータベースは作業している人によって形状が異なることがあるのでその点を考慮しているのではないかという結論に至りました。

また以下のSOFでの質問:

every time we merge branches on GitHub, we get merge conflicts with our database file.

という問題への解答が

Add your database file to .gitignore. Then you can keep it in its current location, but it will not be under version control.

だったことからも以上の結論が推測されます。

参考にしたリンク

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2