適用場景:在某個分支上想恢復到之前某個提交的版本,且那個版本之後提交的版本都不要了
操作步驟:
1. 切換到指定分支
git checkout 分支名
2. git log 查看提交版本號信息
git log
像下面的 commit 後面的那一串就是版本號
commit a550c5581814206a2096c1a5fee1caeed01d6a30
Author: test <[email protected]>
Date: Tue Feb 4 00:38:15 2020 +0800
StringBuffer直接改變原字符串,char數組和字符串的轉換
commit a2456b6825a4cab009d53ba8bb2cd8a4eb425f6b
Author: test <[email protected]>
Date: Tue Feb 4 00:23:53 2020 +0800
3. git reset --hard 版本號
git reset --hard 版本號
比如
git reset --hard a2456b6825a4cab009d53ba8bb2cd8a4eb425f6b
4. git push -f 強制提交
git push -f