我知道你可以回到之前的提交记录,但好像历史记录并不会消失。如何回到先前的提交记录,并确保在此之后的提交记录永远消失?
我知道你可以回到之前的提交记录,但好像历史记录并不会消失。如何回到先前的提交记录,并确保在此之后的提交记录永远消失?
Git reset 命令可以实现这一点。
您可以运行 git reset --hard
命令恢复到以前的提交。然后, 运行 git push --force
命令来清除服务器上该提交之后的所有提交。
git clone <repo_url> #clone your azure git repo to local
git checkout <branch>
git reset --hard <commithash> #revert back to a the previous commit
git push --force #push to remote server
在本地运行上述git命令后,您会发现在Azure DevOps Git上,之后的提交记录都消失了。