为Django网站创建.gitignore文件 [英] Creating a .gitignore file for a Django website

查看:112
本文介绍了为Django网站创建.gitignore文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备将我现有的Django项目(我已经在本地环境中运行)推送到Bitbucket存储库,以便可以在公共服务器上运行它.目前,我感觉在本地开发中创建了很多文件,需要将它们添加到 .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 文件夹中删除文件.那里还有很多我不知道他们做什么的东西-我知道并不是所有的东西都是必需的.任何建议表示赞赏.

I found this .gitignore file on github however I still feel it's missing some things, for example it doesn't seem to remove files from each migrations folders. There's also a lot of stuff there that I don't know what they do - I understand not all of it is needed. Any advice is appreciated.

推荐答案

您可以考虑使用 gitignore 专为Django项目量身定制.

You could consider a gitignore tailored for Django project instead.

请不要忘记,如果您已经添加并提交了文件夹内容,则需要删除它们,然后.gitignore才能生效.

And don't forget that, if you already have added and committed a folder content, you will need to remove them before your .gitignore can take effect.

git rm --cached -r afolder/

但是,默认情况下,不会忽略 migration .(您可以跳过其中一些迁移步骤)
正如 Ora 在评论中所指出的,请参阅"

However, by default, migration is not ignored. (you can skip some of those migration steps)
As pointed out by Ora in the comments, see "Should I be adding the Django migration files in the .gitignore file?".

因此,请勿将 migration/添加到您的 .gitignore 中.

So, do not add migration/ to your .gitignore.

这篇关于为Django网站创建.gitignore文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆