git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
# Undo the last commit locally
git rebase -i HEAD~1
# Push to update the remote branch
git push --force
git reset HEAD^ --hard
git push <<remote>> -f
//Undo the last commit locally
git reset HEAD^
//then push to the remote repository
git push origin +HEAD
1
$git rebase -i HEAD~2
git push origin +HEAD^:<name of your branch, most likely 'master'>
// after adding a file mistakenly to commit
// git log to see how many times you have committed the changes so as to know how many times
// you would reset the commit
git log
// after getting how many times you would reset for example 5 times, then run below code 5 times
git reset HEAD~1
// then proceed to add again
git add .