打赏

git pull 撤销误操作

比如你当前所在的分支是master,但是执行了git pull origin branches,这时需要回滚回去,可以用一下步骤:

1、运行git reflog命令查看你的历史变更记录,如下:

$ git reflog
ac4af85 (HEAD -> ka_service) HEAD@{0}: reset: moving to ac4af85
ebb64e4 (origin/ka_service) HEAD@{1}: pull: Merge made by the 'recursive' strategy.
ac4af85 (HEAD -> ka_service) HEAD@{2}: commit: 在线课程导出的修改
3f59f2f HEAD@{3}: commit: 修改报名相关
8e951a4 HEAD@{4}: pull: Merge made by the 'recursive' strategy.
9c84be6 HEAD@{5}: commit: 修改相关课程
7978b47 HEAD@{6}: pull: Merge made by the 'recursive' strategy.

2、然后用git reset --hard HEAD@{n},(n是你要回退到的引用位置)回退。

比如上图可运行 git reset --hard ac4af85

3  执行后再次 git reflog 会看到 reset: moving to ac4af85

posted on 2020-04-22 10:17  法尔克斯  阅读(588)  评论(0编辑  收藏  举报

导航

打赏