Creating a .gitignore file for a Django website

Zor*_*gan 11 python git django gitignore

I'm ready to push my existing Django project (which i've been running in a local environment) to a Bitbucket repository so I can run it on a public server. At the moment I feel like there's a lot of files created in local development that needs to be added to .gitignore.

在 github 上找到了这个.gitignore文件,但是我仍然觉得它缺少一些东西,例如它似乎没有从每个migrations文件夹中删除文件。还有很多我不知道他们做什么的东西——我知道并不是所有的东西都是需要的。任何建议表示赞赏。

Von*_*onC 13

您可以考虑gitignore为 Django 项目量身定制

并且不要忘记,如果您已经添加并提交了文件夹内容,则需要在 .gitignore 生效之前将其删除。

git rm --cached -r afolder/
Run Code Online (Sandbox Code Playgroud)

但是,默认情况下,migration不会被忽略。(您可以跳过其中一些迁移步骤
正如Ora在评论中指出的那样,请参阅“我应该在文件中添加 Django 迁移.gitignore文件吗? ”。

所以,不要添加migration/到你的.gitignore.

  • 你不应该忽略迁移。在这里看到:/sf/ask/1962458361/ (2认同)