# Undo the last commit locally
git rebase -i HEAD~1
# Push to update the remote branch
git push --force
//Undo the last commit locally
git reset HEAD^
//then push to the remote repository
git push origin +HEAD
1
$git rebase -i HEAD~2
// 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 .