使用与git-reset手册页面相同的表表示形式,git存储库中有以下状态:
working index HEAD
------------------
B B A什么命令会把各州变成那些州?
working index HEAD
------------------
A B A换句话说,我希望将工作目录状态“重置”为HEAD状态,但不要触及暂存区域状态。
发布于 2016-09-09 07:59:40
这样做的一种方法是在执行git checkout之前和之后手动备份和恢复索引。
cp .git/index .git/index.bak
git checkout HEAD -- .
mv .git/index.bak .git/index发布于 2022-02-02 18:02:08
发布于 2016-09-09 08:11:08
我认为这应该是可行的(订购事宜)。
您首先需要提交索引中的内容(为了使头看起来像这个索引和工作目录:B --使用您的注释):
git commit因此,头部将是B(使用您的注释)。
现在,打印reflog,因为我们需要B的散列:
git reflog现在,使用不同的选项运行几个reset命令:
git reset --hard HEAD~ # makes the working directory, the index, and the HEAD looks like this: A, A, A (respectively)
git reset --mixed <hashOfB> # makes the working directory, the index, and the HEAD looks like this: A, B, B (respectively)
git reset --soft HEAD~ # makes the working directory, the index, and the HEAD looks like this: A, B, A (respectively)我希望这能帮到你。
https://stackoverflow.com/questions/39405942
复制相似问题