git delete推送提交并删除历史记录条目

n00*_*exe 3 git commit

我已经对存储库进行了一些更改。

我想从存储库中删除最后一次提交,并永久删除历史记录条目。

我怎样才能做到这一点?

Opa*_*pal 10

尝试:

git checkout <branch> // replace branch with a name of the branch you worked on
git reset --hard HEAD~1 // this command removes the latest commit
git push --force-with-lease origin <branch> // push the changes to the remote
Run Code Online (Sandbox Code Playgroud)

如果在进行上述操作时没有人修改遥控器,则将被接受,否则可能会被拒绝。进一步的步骤取决于是否可以使用-f代替--force-with-lease。如果是这样,它将覆盖其他人的更改。如果没有,则必须更改历史记录才能完成。