在Git中恢復由SHA哈希提交?我不清楚如何git revert工作。例如,我想在頭部后面恢復提交六次提交,恢復中間提交之間的所有更改。說它的SHA哈希是56e05fced214c44a37759efa2dfc25a65d8ae98d。那我為什么不能做以下事情:git revert 56e05fced214c44a37759efa2dfc25a65d8ae98d
3 回答

MMMHUHU
TA貢獻1834條經驗 獲得超8個贊
如果要在當前HEAD上提交具有不同提交的確切狀態,撤消所有中間提交,則可以使用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"

Helenr
TA貢獻1780條經驗 獲得超4個贊

婷婷同學_
TA貢獻1844條經驗 獲得超8個贊
它恢復了所述提交,即添加與其相反的提交。如果要簽出早期版本,請執行以下操作:
git checkout 56e05fced214c44a37759efa2dfc25a65d8ae98d
- 3 回答
- 0 關注
- 526 瀏覽
添加回答
舉報
0/150
提交
取消