git“重置" workdir到HEAD而不接触暂存区 [英] git "reset" workdir to HEAD without touching staging area
本文介绍了git“重置" workdir到HEAD而不接触暂存区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用与git-reset
手册页中相同的表表示形式,我在git
存储库中具有以下状态:
Using the same table representation as in git-reset
manual page, I have these states in my git
repository:
working index HEAD
------------------
B B A
什么命令将状态更改为那些状态?
What command will change the states to those?
working index HEAD
------------------
A B A
换句话说,我想将工作目录状态重置"为HEAD
状态,但不要触及暂存区状态.
I other word, I want to "reset" the working directory state to the HEAD
state, but without touching the staging area state.
推荐答案
一种可行的方法是在执行git checkout
之前和之后手动备份和还原索引:
A plumbing way of doing this is to manually backup and restore the index before and after doing git checkout
:
cp .git/index .git/index.bak
git checkout HEAD -- .
mv .git/index.bak .git/index
这篇关于git“重置" workdir到HEAD而不接触暂存区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文