如何返回到最新的远程提交 git

How to go back to latest remote commit git

我不得不回到我的代码在本地的早期提交,所以我使用 git reset --hard <tag> 回到那个提交,我现在如何回到最新的提交是什么(根据远程存储库)?

假设自从上次与远程跟踪分支同步后您没有进行过提取,那么您应该能够将您的分支重置为上次同步时远程中的最新提交:

git reset --hard origin/yourBranch

如果你想将你的分支与最新的远程同步,你可以尝试拉取:

git pull origin yourBranch

但请务必先提交所有工作,并预计可能会出现合并冲突。