我应该在.gitignore文件中添加Django迁移文件吗? [英] Should I be adding the Django migration files in the .gitignore file?

查看:776
本文介绍了我应该在.gitignore文件中添加Django迁移文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在 .gitignore 文件中添加Django迁移文件吗?

Should I be adding the Django migration files in the .gitignore file?

由于迁移冲突,我最近收到了很多git问题,并且想知道我是否应该将迁移文件标记为忽略。

I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.

如果是这样,我将如何添加我在我的应用程序中的所有迁移,并将它们添加到 .gitignore 文件?

If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?

推荐答案

Django迁移文档


每个应用的迁移文件都存在于迁移目录,并被设计为承诺并作为其代码库的一部分分发。您应该在开发机器上进行一次,然后在同事的机器,分段计算机以及最终的生产计算机上运行相同的迁移。

The migration files for each app live in a "migrations" directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your development machine and then running the same migrations on your colleagues’ machines, your staging machines, and eventually your production machines.

如果您遵循此过程,您不应该在迁移文件中获得任何合并冲突。

If you follow this process, you shouldn't be getting any merge conflicts in the migration files.

为了减轻您目前拥有的任何问题,您应该指定哪个存储库或分支具有权威版本的迁移文件,然后使用 git的属性机制,为这些文件指定合并策略our。这将告诉git总是忽略这些文件的外部更改,并且更喜欢本地版本。

To mitigate any issues you currently have, you should specify which repository or branch has the authoritative version of the migration files, and then use git's attribute mechanism to specify the merge strategy "ours" for these files. This will tell git to always ignore external changes to these files and prefer the local version.

这篇关于我应该在.gitignore文件中添加Django迁移文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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