gpt4 book ai didi

git - 如何在 git 硬重置后恢复上次提交?

转载 作者:IT王子 更新时间:2023-10-29 01:29:45 26 4
gpt4 key购买 nike

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

步骤:

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

有什么办法可以解决这个问题来恢复我的更改?

最佳答案

要查看对 001-branch 所做的所有更改,您可以执行 git reflog 001-branch,但是,您认为您在 001-branch 中所做的很可能是您在另一个分支中所做的,所以您可能需要使用 git reflog 查看所有更改。

关于git - 如何在 git 硬重置后恢复上次提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19898557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com