git reset --soft HEAD^ 撤销上一次提交,修改的文件还在
git reset --hard HEAD^ 撤销上一次提交,修改的文件被还原
delete commit alread push to remote respository:
First, remove the commit on your local repository. You can do this using git rebase -i
. For example, if it's your last commit, you can do git rebase -i HEAD~2
and delete the second line within the editor window that pops up.
Then, force push to GitHub by using git push origin +master
or:
git push -f origin <branch-name>
delete middle commit like this:
git rebase --onto <remove-commit-sha> <branch-name>