有时我们需要回滚git上已经提交的代码,特别是已经提交到github上的代码。可以使用如下步骤:
1、 git reflog
$ git reflog1bd6100 (HEAD -> master) HEAD@{0}: commit: Site updated: 2018-05-10 12:20:40f681615 HEAD@{1}: commit: Site updated: 2018-04-25 19:31:2578f096f HEAD@{2}: commit: Site updated: 2018-04-25 19:11:2314b480b HEAD@{3}: commit: Site updated: 2018-04-24 20:01:27COPY
2、 git reset --hard version
$ git reset --hard f681615HEAD is now at f681615 Site updated: 2018-04-25 19:31:25COPY
3、 git log
$ git logcommit f68161540b8c3400c4ab4a35eef67039c732781d (HEAD -> master)Author: drunkdream <drunkdream@gmail.com>Date: Wed Apr 25 19:31:53 2018 +0800Site updated: 2018-04-25 19:31:25COPY
4、 git push --force
$ git push --forceTotal 0 (delta 0), reused 0 (delta 0)To github.com:drunkdream/xxx.git+ 1bd6100...f681615 master -> master (forced update)COPY
Related Issues not found
Please contact @drunkdream to initialize the comment