简体   繁体   English

恢复git reset HEAD到最后一次提交更改

[英]Revert git reset HEAD to last commit changes

By mistake i have executed below commands 我错误地执行了以下命令

git reset HEAD
git reset 'HEAD@{1}'
git reset ORIG_HEAD

Now my latest changes are not showing on remote server. 现在,我的最新更改未显示在远程服务器上。

Which command need to execute i'm on dev branch 我需要在开发分支上执行哪个命令

You can copy your desired commit you want to back from git log --walk-reflogs . 您可以从git log --walk-reflogs复制desired commit Then reset your branch ( dev ) to the commit-sha . 然后reset您的分支( devresetcommit-sha

$ git checkout dev
$ git log --walk-reflogs        # copy desired commit-sha

$ git reset --hard <commit-sha> # reset 'dev' branch on the commit

$ git push -f origin HEAD       # force(-f) push as history is changed 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM