[ACCEPTED]-How to really delete a commit on VSTS / Azure-devops-azure-devops
You can try the following steps to remove 19 an entire commit:
Git clone the specific 18 branch to a local repository :
git clone --single-branch --branch branchname https://xxx@dev.azure.com/xxx/0508-t/_git/0508-t
Get the SHA of 17 the commit which you want to be deleted:
Navigate 16 to
https://dev.azure.com/{organization}/_git/{Project}/commits
page -> Select the specific commit 15 -> Click More -> Copy Full SHA . (Reference below sceenshot)Run 14 this command in git bash to remove the commit 13 in local repository :
git rebase -p --onto SHA^ SHA
Just replace "SHA" with 12 the reference you want to get rid of (the 11 one you get from the step 2). The "^" in 10 that command is literal. For example :
git rebase -p --onto 7e5661e7545013145dc7569edbe7c99f4b8d9671^ 7e5661e7545013145dc7569edbe7c99f4b8d9671
Force 9 git push to origin:
git push origin +test
Notice the +
sign before 8 the name of the branch you are pushing, this 7 tells git to force the push. It is worth 6 to mention that you should be very careful 5 when deleting commits because once you do 4 it they are gone forever. Also, if you are 3 deleting something from a remote repository 2 make sure you coordinate with your team 1 to prevent issues.
You do not need to physically delete the commit that 16 you do not want in your project. this is 15 not a friendly solution to the git purpose 14 i.e. its main role to track files changes 13 (or versioning).
Simply try to change your 12 vision about the git to get the correct 11 sense in exploring new features you never 10 tried before.
Here, in your case, I suggest 9 using the revert option that allows you 8 to push a new commit that undoes the change 7 of specific previous commit.
In VS > Team 6 Explorer (right side) > Branches > right-click 5 the target branch > view history. this will 4 open a new vs window with a list of committed 3 modifications
right-click on the commit 2 you want to undo > select revert
then push 1 the reverted commit
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.