git 本地文件修改错误,重新取回服务器历史版本

1. 重新取回历史版本

git log

git checkout (这里写 上面查询出来 commit 后面的哈希值)


2. 此时使用git push会碰到如下问题:

$ git push

fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>

解决方案:

git checkout -b temp 切换到一个临时的分支

git checkout master 再切换回主分支

git push

原文地址:https://www.cnblogs.com/alantop/p/13476627.html