Removing duplicate db migrations from git repository

醉酒当歌 提交于 2019-12-31 22:28:15

问题


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.

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

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

20101007030431_create_favorites.rb
20101012173735_create_favorites.rb

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?

Thanks in advance.


回答1:


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


来源:https://stackoverflow.com/questions/4017571/removing-duplicate-db-migrations-from-git-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!