Hello @Tanner Eull
Thank you for reaching out to Microsoft Q & A!
If the branch has already been pushed and shared, the recommended approach is to revert the unwanted commits rather than reset or rebase the branch. Reverting creates new commits that undo the changes while preserving repository history.
Please follow below steps:
- Find the commit IDs: git log --oneline
- Identify the last known good commit from 5 commits ago.
- Revert the commits after that point: git revert <commit ID>
This creates new commits that undo the changes while preserving history.
- If conflicts occur, resolve them and run: git revert --continue
Or cancel the operation with: git revert --abort
- Push the new revert commits to Azure Repos.
Visual Studio 2022
- Go to Git > View Branch History.
- In History, right-click the commit you want to undo.
- Select Revert.
If the branch has not been shared, a reset may also be an option. However, operations such as git reset --hard, rebasing, or force-pushing rewrite branch history and should be used with caution because they can result in lost work and history mismatches between local and remote repositories.
For additional guidance, please refer to Microsoft's documentation:
Please "Accept the Answer" if this information helped you. This will help us and others in the community as well.