如何回滚 Git Pull/Rebase

huangapple go评论67阅读模式
英文:

How to rollback a Git Pull/Rebase

问题

我有一个严重的问题。

基本上,我上次提交到项目是一个月前,今天我需要进行新的提交 - 自那时远程存储库上已经进行了文档更改。我对Git相对较新,上次尝试推送我的提交时出现问题,因为远程发生了变化,所以我认为我应该先拉取这些更改,然后再推送我的本地更改,但是在执行此拉取后,我的本地存储库以及整个Visual Studio项目都已还原到一个月前的状态 - 这是大量的工作丢失。据我所见,以前的文件更改没有本地痕迹。

有人能告诉我有方法来撤销这个吗?

英文:

I have a serious problem.

Basically my last commit to a project was a month ago and I needed to make a new one today - since then a documentation change has been made on the remote repo. I am relatively new to git and had issues trying to push my commits last time because of a change on the remote and so I thought I should pull these changes first and then push my local changes however un doing this pull my local repo, as well as my entire visual studio project has been reverted back to how it was a month ago - thats a lot of work lost. As far as I can see there is no local trace of the previous file changes

Somebody please tell me there's a way to undo this!

答案1

得分: 1

以下是已翻译的内容:

There's usually always a way to do undo something like in this git. Without really knowing your commit history/tree it's hard to give an exact list of commands to get you back the point where you were before, but generally:

Use git log to find the commit hash of the latest "safe" commit

git checkout <safe commit hash>

git reset --hard

英文:

There's usually always a way to do undo something like in this git. Without really knowing your commit history/tree it's hard to give an exact list of commands to get you back the point where you were before, but generally:

Use git log to find the commit hash of the latest "safe" commit

git checkout &lt;safe commit hash&gt;

git reset --hard

huangapple
  • 本文由 发表于 2023年3月31日 23:28:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900255.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定