我不清楚如何git revert工作。例如,我想恢复到头部后面的六个提交,恢复中间提交中的所有更改。
git revert
说它的SHA哈希是56e05fced214c44a37759efa2dfc25a65d8ae98d. 那为什么我不能这样做:
56e05fced214c44a37759efa2dfc25a65d8ae98d
git revert 56e05fced214c44a37759efa2dfc25a65d8ae98d
如果您想在当前 HEAD 之上以不同提交的确切状态提交,撤消所有中间提交,那么您可以使用reset创建索引的正确状态来进行提交。
reset
# Reset the index and working tree to the desired tree # Ensure you have no uncommitted changes that you want to keep git reset --hard 56e05fced # Move the branch pointer back to the previous HEAD git reset --soft "HEAD@{1}" git commit -m "Revert to 56e05fced"