【问题标题】:undo git pull of project撤消项目的 git pull
【发布时间】:2020-09-25 23:33:41
【问题描述】:

我在本地项目中错误地拉取 Github 上的项目,因此本地项目中的所有项目都被删除并由 github 项目替换。

注意: Github 上的项目是 Flutter 项目,本地项目是 Laravel one。

如何找到我的 Laravel 项目?

这一些代码可能有助于解决这个问题

$ git status .
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
    test.sh
nothing added to commit but untracked files present (use "git add" to track)

【问题讨论】:

  • Pull 不会删除任何内容(至少您无法恢复)。您能给我们提供更多背景信息吗?
  • git pull 相当于运行fetch,然后运行merge。你所有的提交仍然存在(你最近的状态很可能在HEAD^)。如果您没有本地更改,则可以进行硬重置。如果您有本地更改,请在重置之前存储。

标签: git git-pull pull


【解决方案1】:

这对我有用。

首先你必须找出git pull之前的commit-hash。 (使用git log 非常简单)

然后,您可以将本地存储库设置回上一次提交的状态。例如(commit-hash 必须与你的调整)

git reset --hard abc1234a

您也可以使用git reflogreset 回看您的本地存储库git reset --hard HEAD@{1}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-10
    • 2011-01-13
    • 1970-01-01
    • 2011-08-14
    • 2013-11-20
    • 2016-02-08
    • 2017-08-06
    相关资源
    最近更新 更多