移除GitHub上的commit

来源:互联网 发布:sicp python pdf 编辑:程序博客网 时间:2024/04/27 16:41

参看stackoverflow上的回答

http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github


Note: please see alternative to git rebase -i in the comments below.

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.

See Git Magic Chapter 5: Lessons of History - And Then Some for more information (i.e. if you want to remove older commits).

Oh, and if your working tree is dirty, you have to do a git stash first, and then agit stash apply after.


0 0