delete commit from remote code example

Example 1: delete branch from remote

// delete branch locally
git branch -d localBranchName

//delete local branch that is unmerged
git branch -D localBranchName

// delete branch remotely
git push origin --delete remoteBranchName

Example 2: delete remote commit

git reset --hard 
git push --force

Example 3: how to undo a commit from remote

git reset --hard HEAD~3
git push -f

Example 4: remove last commit from remote

git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit

Example 5: delete remote commit

git reset --hard 

Example 6: delete a pushed commit

$git log --pretty=oneline --abbrev-commit

Tags:

Misc Example