从 git 存储库中删除重复的数据库迁移 [英] Removing duplicate db migrations from git repository

查看:12
本文介绍了从 git 存储库中删除重复的数据库迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Rails 应用程序部署到 Heroku,但遇到了一些基本的 git 问题.我对这一切都很陌生——rails、git、heroku——所以我担心我迷失了可能是一个相当基本的概念.

I'm trying to deploy a rails app to Heroku and I'm running into some basic git problems. I'm new to this all -- rails, git, heroku -- so I'm afraid I'm getting lost on what's probably a fairly basic concept.

我已将应用程序推送到 Heroku,但是当我迁移数据库 ($ heroku rake db:migrate) 时,我不断收到以下错误:

I've pushed the app to Heroku, but when I'm migrating the db ($ heroku rake db:migrate), I keep getting the following error:

rake aborted!
Multiple migrations have the name CreateFavorites

查看我的github仓库,果然有两个迁移:

Checking my github repository, and sure enough, there are two migrations:

20101007030431_create_favorites.rb
20101012173735_create_favorites.rb

第一个文件 -- 20101007030431_create_favorites.rb -- 在我的本地应用程序中不存在,但在我提交后它仍然在 github 存储库中.如何删除此文件并使我的存储库和本地应用程序同步?

The first file -- 20101007030431_create_favorites.rb -- does not exist in my local app, and yet it's still in the github repository after I commit. How can I remove this file and get my repository and local app in sync?

提前致谢.

推荐答案

如果你输入git status"应该会显示不一致.它会这样说:

If you type "git status" it should show the inconsistency. It will say something like this:

# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    db/migrate/20101007030431_create_favorites.rb

所以只需按照那里的说明进行操作即可.要将其从存储库中永久删除,请键入:

So just follow the instructions there. To permanently remove it from the repository, type:

git rm db/migrate/20101007030431_create_favorites.rb

这篇关于从 git 存储库中删除重复的数据库迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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