Skip to content

Instantly share code, notes, and snippets.

@52cik
Created October 9, 2016 06:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 52cik/6c0fa91ee31d9b88966aeac1c3c4aa3c to your computer and use it in GitHub Desktop.
Save 52cik/6c0fa91ee31d9b88966aeac1c3c4aa3c to your computer and use it in GitHub Desktop.
git 强行回退
假设你有3个commit如下:
commit 3
commit 2
commit 1
其中最后一次提交commit 3是错误的,那么可以执行:
git reset --hard HEAD~1
你会发现,HEAD is now at commit 2。
然后再使用git push --force将本次变更强行推送至服务器。这样在服务器上的最后一次错误提交也彻底消失了。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment