2013-02-13 89 views

回答

4

虽然previous answer已被接受,我不认为这真的 回答题。它不会将索引留在初始状态 ,而是在更新工作树后重置索引以匹配HEAD。 这将失去使用git add完成的任何工作。

相反,我会使用一个临时索引:

export GIT_INDEX_FILE=.git/tmpindex 
git read-tree abc123 # Read commit into (temporary) index file 
git checkout . # Update working tree with contents of (temporary) index 
rm $GIT_INDEX_FILE 
unset GIT_INDEX_FILE 

这将真正离开正常指标在原来的状态。

+0

漂亮。我当然不是git-guru,所以低级的东西超出了我的想象。 – Chowlett 2013-02-14 09:29:21

1

它看起来就像你不能做到这一点的一个命令,但是你应该能够有两个:

$> git cherry-pick -n abc123  # cherry-pick to index and WC, no commit 
$> git reset      # revert index 
相关问题