LMLPHP后院

git pull 误操作后如何恢复技术

maybe yes 发表于 2017-05-24 23:30

习惯使用 git pull 不是无缘无故的,因为它确实好用,能更新整个项目所有分支

但是,如果出错了,或者本身已经是最新的代码,误操作导致代码被污染怎么办?

$ git reflog feature-20170415

72f5ce3 feature-20170415@{0}: pull origin feature-20170415: Merge made by the 'recursive' strategy.
22a886b feature-20170415@{1}: rebase -i (finish): refs/heads/feature-20170415 onto a9ba6a4f760a9126f87ad49a0fd6c34834157df4
faa0e73 feature-20170415@{2}: commit: .
a9ba6a4 feature-20170415@{3}: rebase -i (finish): refs/heads/feature-20170415 onto 44102be15065bdf270a153a73a900642636a6a54
91f59b6 feature-20170415@{4}: commit: .
44102be feature-20170415@{5}: commit: .
723f02a feature-20170415@{6}: branch: Created from HEAD

查看 reflog,然后选择恢复的点:

$ git reset --hard feature-20170415@{1}
相关文章
2024-07-13 04:11:49 1720815109 0.007613