Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5960877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:53:12+00:00 2026-05-22T18:53:12+00:00

What are the steps I can do to re-start cleanly from the previous perfectly

  • 0

What are the steps I can do to re-start cleanly from the previous perfectly working Git checkout tree with all old files (new files deleted), correct migrations (new tables/migrations dropped), etc?

Here’s the situation. I’m learning Rails and a couple of times I messed up and hence, I did git checkout -f (without committing anything) to start cleanly from that perfectly working code. However, I found that newly created files remained and I had to delete them manually and rake db:migrate had errors saying the tables were already existing.

Here are some of my errors:

Sayanee:depot sweska$ rake db:migrate
(in /Applications/XAMPP/xamppfiles/htdocs/rails_projects/TUTORIALS/depot)
==  CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: table "users" already exists: CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "hashed_password" varchar(255), "salt" varchar(255), "created_at" datetime, "updated_at" datetime) 

(See full trace by running task with --trace)
Sayanee:depot sweska$ rake db:reset
(in /Applications/XAMPP/xamppfiles/htdocs/rails_projects/TUTORIALS/depot)
db/test.sqlite3 already exists
db/test.sqlite3 already exists
db/development.sqlite3 already exists
-- create_table("carts", {:force=>true})
   -> 0.0033s
-- create_table("line_items", {:force=>true})
   -> 0.0172s
-- create_table("orders", {:force=>true})
   -> 0.0032s
-- create_table("products", {:force=>true})
   -> 0.0030s
-- create_table("users", {:force=>true})
   -> 0.0049s
-- initialize_schema_migrations_table()
   -> 0.0095s
-- assume_migrated_upto_version(20110522103119, "db/migrate")
   -> 0.0153s
You have 1 pending migrations:
  20110523004950 CreateUsers
Run "rake db:migrate" to update your database then try again.

So my questions are:

  1. Which git command to use to make a clean shift back to the previous commit?
  2. How can I know what are the new files created so that I can delete them? Or should I commit the current not-working codes and then shift back?
  3. How can I make a clean shift to the previous migrations when I do not know how many steps to go back using the rake db:rollback STEP=3? Or is there any command like git status which can list all my previous migrations and their names?
  4. Am i missing anything else that I should consider when moving back to my previous working git commit and start fresh from there?

Many thanks! And with the answers, I will list the steps here!

Steps to create a clean start from the previous git checkout:

  1. git reset –hard HEAD^ #hard reset
  2. git clean -f #delete all new files
  3. rake db:migrate
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:53:12+00:00Added an answer on May 22, 2026 at 6:53 pm

    You could always reset your commit to the previous.

    git reset --hard HEAD^
    

    Remember resetting hard resets the index and the working tree, so any tracked files will be discarded. If you don’t want to discard anything, you can do a –soft reset instead.

    For more information, the git reset docs has some well written examples:

    http://git-scm.com/docs/git-reset

    Since your rails app creates the sqlite database file, resetting the current tree to a previous state will not remove untracked files. To remove those untracked files (your sqlite database), you can remove that sqlite database file. If you want to clean the entire tree, you can run:

    git clean -f
    

    By resetting and cleaning your git working tree, it will go back to the state where you initially checked out at that particular commit.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that we can start new activity with the steps as follows :
In accordance with the steps from MSDN , I can debug .net framework source
I created app which user can start from menu and from icon. I do
Windows 7 has a wonderful facility called problem steps recorder . You can start
http://en.wikipedia.org/wiki/Diamond_problem I know what it means, but what steps can I take to avoid
Can anyone post the steps for integrating mercurial to phped. I followed the following
Can anyone list the steps to integrate PHP_Beautifier in phped.
Can someone give specific steps on how to implement hosting of a Django-based website
Can anyone paste simple steps to integrate Spring security and CAS over here for
Can you please tell me the steps I need to follow in order to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.