我想恢复到我的应用程序的备份副本 [英] I want to revert to a backed up copy of my App
问题描述
我已经研究过这个话题,但是我担心自己对Git的经验太少,可能会通过尝试不同的东西而导致更多的问题,所以我发布了一些信息以找到恢复到我的应用的以前状态的最佳方式。
我提交了更改并删除了以前的分支,但是在我在本地备份应用程序到外部驱动器之前没有。
一切工作正常(功能方面),正如我在最近的变化之前部署到Heroku仍然有效的证明。
我没有为新的改变创建一个分支,我再也不会这样做了,而我正在从事主人工作。虚假的信心...
因此,因为一切都变得非常糟糕,我决定复制备份的应用程序并开始新的...但这不起作用。
我认为这可能是一个简单的问题,即恢复对主人的未提交更改,但我有点冻结,担心我可能会失败。 p>
你能帮忙吗???
我正在使用rails 3.2,ruby 1.9.3,git 1.7.4.4
更新
我已经使用git reset --hard HEAD和现在终端告诉我
HEAD现在在820f417微。
我遇到的问题是:
我不知道这可能会或可能不会更改我在textmate内部编辑过的文件,并将其保存到硬盘中。
当我在浏览器,我收到错误:
StaticPagesController中的ActiveRecord :: StatementInvalid#home
找不到表'用户'
跟踪:
app / helpers / sessions_helper.rb:46:在 user_from_remember_token'
current_user'
app / helpers / sessions_helper.rb:16:in
app / helpers / sessions_helper.rb:9: signed_in?'
app / controllers / static_pages_controller.rb:4:in home'
还原提交涵盖在 Git Book :
$ b
如果您没有提交更改,则无法恢复为这些更改。除非我误解了你的意思,并且你希望恢复未提交的变更回到最后提交的版本,这种情况很简单。
下面是一个例子:
这是四次修改后的文件。
> cat file
这是修订4
获取状态:
> git status
#分支主
#已更改但未更新:
#(使用git add< file> ...来更新将提交的内容)
# (使用git checkout - < file> ...放弃工作目录中的更改)
#
#修改:文件
#
没有更改添加到提交使用git add和/或git commit -a)
恢复上次提交的版本:
> git reset --hard HEAD
HEAD现在位于e0d512a修订版3
查看文件:
> cat file
这是修订3
恢复上次提交:
> git恢复HEAD
完成一个还原。
[master 92a575c]还原Revision 3
1个文件已更改,1个插入(+),1个删除( - )
查看文件:
> cat file
这是修订2
查看修订历史记录:
> git的日志
犯92a575c481c69fc1dd809ba02a63009141f95b96
日期:星期五3月2日17时13分36秒2012 1100
还原 修订版3
此回复提交e0d512acebbfb3891888dc59074f7d1f0748bba6 。
犯e0d512acebbfb3891888dc59074f7d1f0748bba6
日期:星期五3月2日17时11分25秒2012 1100
修订版3
犯efc6d5af434c56991dabee43f36bc6e7ff284da7
日期:星期五3月2日17时11分01秒2012 1100
修订2
犯8b73c59bb517df2589dcd0285a6d19045882ad8e
日期:星期五3月2日17点10分二十秒2012 + 1100
修订1
>
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
home'
Reverting commits is covered in the Git Book:
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
>
这篇关于我想恢复到我的应用程序的备份副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!