I want to revert to a backed up copy of my App

I have researched this topic, but am afraid I have too little experience with Git and may be causing more problems by trying out different things, so I am posting to find out the best way to revert to a previous state of my App.

I committed the changes and deleted the previous branches, but not before I backed up the app locally on an external drive.

Everything was working fine (function-wise), as evidenced by my deployment to Heroku, which is still working, prior to my most recent changes.

I failed to create a branch for the new changes, something I will never do again, and I was working off the master. False confidence...

So, since everything went so horribly wrong, I decided to copy over the backed up App and start new... but that didn't work.

I think it could be a simple matter of reverting to uncommitted changes on the master, but I am a little frozen with fear that I may make a misstep.

Can you help???

I am working on rails 3.2, ruby 1.9.3, git 1.7.4.4

Update


I have used git reset --hard HEAD and now terminal tells me HEAD is now at 820f417 micro.

Problems I'm having are:

I don't know how this may or may not change files I have edited inside textmate and saved to the hard drive.

When I open the app in the browser, I am getting the error:

ActiveRecord::StatementInvalid in StaticPagesController#home

Could not find table 'users'

Trace: app/helpers/sessions_helper.rb:46:in user_from_remember_token' app/helpers/sessions_helper.rb:16:in current_user' app/helpers/sessions_helper.rb:9:in signed_in?' app/controllers/static_pages_controller.rb:4:in signed_in?' app/controllers/static_pages_controller.rb:4:in home'


Reverting commits is covered in the Git Book :

  • Undoing in Git - Reset, Checkout and Revert
  • If you haven't committed the changes, you can't revert to them. Unless I misunderstood you and you wish to revert un-commit changes back to the last committed version, in which case this is easy.

    Here's an example:

    Here's a file after four revisions. Only the first three have been committed.

    > cat file
    This is revision 4
    

    Get the status:

    > git status
    # On branch master
    # Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   file
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    

    Revert to the last committed version:

    > git reset --hard HEAD
    HEAD is now at e0d512a Revision 3
    

    Look at the file:

    > cat file
    This is revision 3
    

    Revert the last commit:

    > git revert HEAD
    Finished one revert.
    [master 92a575c] Revert "Revision 3"
     1 files changed, 1 insertions(+), 1 deletions(-)
    

    Look at the file:

    > cat file
    This is revision 2
    

    View the revision history:

    > git log
    commit 92a575c481c69fc1dd809ba02a63009141f95b96
    Date:   Fri Mar 2 17:13:36 2012 +1100
    
        Revert "Revision 3"
    
        This reverts commit e0d512acebbfb3891888dc59074f7d1f0748bba6.
    
    commit e0d512acebbfb3891888dc59074f7d1f0748bba6
    Date:   Fri Mar 2 17:11:25 2012 +1100
    
        Revision 3
    
    commit efc6d5af434c56991dabee43f36bc6e7ff284da7
    Date:   Fri Mar 2 17:11:01 2012 +1100
    
        Revision 2
    
    commit 8b73c59bb517df2589dcd0285a6d19045882ad8e
    Date:   Fri Mar 2 17:10:20 2012 +1100
    
        Revision 1
    >
    

    If you know the SHA hash of the commit to which you would like to restore your working tree, you can use git checkout <commit> -- to get the specified commit on your current branch.

    If you wish to see the difference in the content of your files, you can use the git diff command. If you want to compare your working tree to what is on the HEAD of your branch (last commit), use git diff HEAD . If you want to see the difference in specific files, list those files at the end of the diff command. You could use git diff to compare with external files, however you should probably focus on determining if your repository still has the commit containing the repository status you need before looking at external back-ups.


    When I want to throw away my recent changes on a committed file, say A.cpp.

    I use git checkout -- A.cpp

    链接地址: http://www.djcxy.com/p/37814.html

    上一篇: 在任何提交之前将主分支移至原始状态

    下一篇: 我想恢复到我的应用程序的备份副本