git删除已push的commit

如果不小心把不改提交的代码或敏感数据(如密码)提交到远程git服务器上,可以使用git reset回滚到上一个commit,并且commit history不留下任何痕迹。

具体做法

1
2
3
4
5
6
7
8
# 1. 找到想要退回到的commit_id
$ git log

# 2. 本地回退到上一个commit_id
$ git reset --hard [commit_id]

# 3. 推送到服务器,一定要加 --force参数
$ git push origin dev.0.0.1 --force

git删除已push的commit
https://www.wekri.com/workflow/git-delete-origin-commit/
Author
Echo
Posted on
January 6, 2019
Licensed under