2013-02-13 24 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 
相關問題