0

Update

I have deleted all the files individually by selecting them on github. But I would like to know about a better solution for this problem.

I made a Ruby on Rails app and I uploaded the code on github. The repo may be seen at:

BrainStorm-Quiz-Website-Engine.

When I was working on the file I added a database named levels by mistake, but then I deleted it(by right-clicking on it and clicking on delete, in the hindsight it was a stupid way) and then pushed a commit.

But now when I clone the repo I get the error

rake aborted!Multiple migrations have the name CreateLevels

How can I remove these multiple migrations from my github repo, so that nobody gets this error on running rake db:migrate

anonn023432
  • 2,940
  • 6
  • 31
  • 63
  • 2
    Here's your (multiple) migrations with the Levels table: https://github.com/rohitbegani/BrainStorm-Quiz-website-engine/search?q=CreateLevels&ref=cmdform – MarcoL Jun 27 '14 at 08:12
  • 1
    possible duplicate of [Deleting Files using Git/GitHub](http://stackoverflow.com/questions/1983346/deleting-files-using-git-github) – Kimmo Lehto Jun 27 '14 at 09:07
  • Thanks @kimmmo, I think this may help – anonn023432 Jun 27 '14 at 10:52

1 Answers1

1

Right now, you have three migrations called 'create_levels', all of which try to create a 'levels' table. To fix this, you need to remove the files, and remove them from Git.

First of all, make sure you're working with an up-to-date, clean git branch:

rohit@foo BrainStorm $ git fetch
rohit@foo BrainStorm $ git status
On branch master
Nothing to commit, working directory clean 

That's what you want to see. If it tells you you're ahead/behind origin/master, do a git push or git pull.

Once you're in a clean git repository, you can remove two of the migrations from your project. I've presumed you want to keep the most recent one. You also have to tell Git that you want the files removed. You can do both tasks at once with git rm:

rohit@foo BrainStorm $ git rm db/migrate/db/migrate/20140123085020_create_levels.rb
rohit@foo BrainStorm $ git rm db/migrate/20140130045634_create_levels.rb

Now you can commit that removal, and push it to your repo:

rohit@foo BrainStorm $ git commit -m "Remove duplicate migrations for creating a levels table." 
rohit@foo BrainStorm $ git push 

And now you should be able to check out that repository and run rake db:migrate without problems.

Alex P
  • 5,942
  • 2
  • 23
  • 30
  • So, I'll have to remove files individually then? They won't be automatically removed from github if I remove them from my local repo and then push it again? – anonn023432 Jun 27 '14 at 10:47
  • You have to remove the files, yes. But you have to remove the files themselves, **and** from Git. The `git rm` command does that, but it's only making changes to your local repo. When you `git push` after `git rm`, they'll be removed from Github then. – Alex P Jun 27 '14 at 10:55