Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Devops Repos - Revert back to a previous commit like the recent ones never existed

I know that you can revert back to a previous commit but it doesn't sound like the history will be gone. How can I revert back to a previous commit and make sure the commits that came after are gone forever?

like image 772
cbrawl Avatar asked Dec 10 '25 05:12

cbrawl


1 Answers

Git reset command can achieve this.

You can run the git reset --hard command to revert back to a previous commit. Then run git push --force command to wipe out all the commits came after this commit on server.

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

After you run above git commands locally. You will see on azure devops git the commits coming after are gone.

like image 174
Levi Lu-MSFT Avatar answered Dec 12 '25 19:12

Levi Lu-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!