某仓库的master分支,推送了错误的内容,导致无法正常工作,需要回退。 假设master当前的commit id 为now_xxx,需要回退到某commit id history_xxx 回退历史commit id # 让文件回退到历史状态 git reset --hard history_xxx # 让master回到最新的commit id,但是保留本地文件 git reset now_xxx # git diff , git commit 检查和提交 git commit -am "roll back to history" # add new branch git checkout -b feature/roll_back_to_history_xxx # publish为legit的方法,简化发布分支的操作 git publish # 通过merge request 合入 master