git remove commit from remote code example

Example 1: git remove remote

$ git remote -v
# View current remotes
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)
> destination  https://github.com/FORKER/REPOSITORY.git (fetch)
> destination  https://github.com/FORKER/REPOSITORY.git (push)

$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

Example 2: delete remote commit

git reset --hard 
git push --force

Example 3: delete a pushed commit

# delete the last commit
$git reset –hard HEAD~

Example 4: how to undo a commit from remote

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

Example 5: remove last commit from remote

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

Example 6: delete remote commit

git reset --hard 

Tags:

Misc Example