How do i remove the latest commit from my repo?
This question already has an answer here:
Yes, it is possible to reset and force push, but you should only do this if you are working alone on your repository.
When pushing a commit to a public/shared repository, that commit is cloned by others into their repositories and will therefore potentially find it's way back to the repository.
The best way is simply to revert your commit using git revert HEAD
. This creates another commit, which simply undoes your last commit.
The rule is: If you did not publish your commit yet, a reset is fine, but if you already published (ie pushed) your commit, a revert is the safe way.
Basically, yes. You may need
git push --force origin master
since it will generally refuse an update that isn't a descendant of the current remote HEAD, but it won't hurt to try your way first and see what it complains about.
I would go with git reset --soft HEAD~1
to keep the files in the index. By doing this, you can modify the erronous files and commit again.
上一篇: 我如何撤消最后一次提交?
下一篇: 我如何从我的回购中删除最新的提交?