git硬重置后如何恢复上次提交? [英] How to recover last commit after git hard reset?

查看:642
本文介绍了git硬重置后如何恢复上次提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在硬重置后恢复以下提交吗?



步骤:

  1)$(master)// ....对文件进行了一系列更改,思考我在分支上工作
2)$ git checkout -b 001-branch //将更改复制到与
一起工作的分支3)$(001-分支)//对文件进行一些更改
4)$(001分支)git commit -a -m'添加并更改内容'
//在这一点上,我只是要拉力大师最新然后重新分配我原来的主人(不是我已经修改的东西)的001分支
5)$(001分支)git checkout master
6)$(master)git reset --hard HEAD
7)$(master)git pull
8)$(master)git checkout 001-branch //返回我的分支和重新绑定我的更改
9)$(001-分支)// oops ...我的更改都是kiboshed,并且我没有看到提交每个git lg


解决方案

解决方案

Ť o看到对你的001分支所做的所有更改,你可以做 git reflog 001-branch ,然而,你可能认为你在001分支中做过的事情可能是你做过的另一个分支,因此您可能需要查看 git reflog 的所有更改。


Can I recover the following commit after a hard reset?

Steps:

1) $ (master) // ....made a bunch of changes to files thinking I was working on a branch
2) $ git checkout -b 001-branch  // copy changes to a branch to work with
3) $ (001-branch) // make some more changes to files
4) $ (001-branch) git commit -a -m 'added and changed stuff'
// at this point I was just going to pull force master to latest then rebase my 001-branch off of original master (not the stuff I had modified)
5) $ (001-branch) git checkout master
6) $ (master) git reset --hard HEAD
7) $ (master) git pull
8) $ (master) git checkout 001-branch // go back to my branch and rebase my changes
9) $ (001-branch) // oops...my changes were all kiboshed and I don't see the commit I did per git lg

Any way out of this mess to recover my changes?

解决方案

To see all the changes made to your 001-branch, you can do git reflog 001-branch, however, chances are what you think you did in 001-branch maybe you did another branch, so you probably need to look into all the changes with git reflog.

这篇关于git硬重置后如何恢复上次提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆