Skip to content

Instantly share code, notes, and snippets.

@cat-kun
Forked from 52cik/git.txt
Created November 25, 2017 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cat-kun/4c32a403221995f888dcdfdf032aed0a to your computer and use it in GitHub Desktop.
Save cat-kun/4c32a403221995f888dcdfdf032aed0a 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