You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 04:57:05