Git回退至未执行git pull前状态的求助(未提交旧变更)
解决方案
1. 回退develop分支到pull前的状态
先切换到develop分支,再硬重置到执行git pull之前的提交节点:
git checkout develop git reset --hard 7fee5206
这一步会让develop分支完全回到你执行pull操作前的状态,对应reflog里HEAD@{24}记录的节点。
2. 恢复correction-testing分支到操作前的状态
切换到correction-testing分支,硬重置到你切换到develop执行pull之前的提交:
git checkout correction-testing git reset --hard 1d76f4e6
从reflog记录来看,HEAD@{25}是你在correction-testing分支执行reset: moving to HEAD的操作,对应的提交1d76f4e6就是你执行pull前该分支的状态。
3. 恢复之前stash的未提交变更
你之前在correction-testing分支执行了git stash暂存未提交变更,现在可以恢复这些内容:
git stash apply
如果希望恢复后直接删除stash记录,可改用git stash pop。
验证状态
执行完以上步骤后,用以下命令确认分支状态是否符合预期:
git log --oneline develop correction-testing git stash list
确保develop分支指向7fee5206,correction-testing分支指向1d76f4e6,且stash的未提交变更已成功恢复。
内容的提问来源于stack exchange,提问作者Grigoryi Evdakov
相关产品推荐
相关产品推荐

