【问题标题】:Restore deleted files恢复已删除的文件
【发布时间】:2015-06-22 11:36:53
【问题描述】:

我在 public/uploads/ 目录中有很多文件。在提交之前,我输入了git rm -- public/uploads/*,然后是git commit -a -m "upload",然后是git push origin master。 在以前的提交照片中不存在。现在我想将它们从 git 恢复到服务器。我该怎么做?

【问题讨论】:

    标签: git commit restore


    【解决方案1】:

    如果它们从未被添加或提交,您将无法恢复它们。

    假设您删除它们的提交的哈希是 abc123。如果您想撤消整个提交,只需执行git revert abc123。如果您想保留提交的其他部分,请执行以下操作:

    git revert abc123 --no-commit
    git reset
    git add public/uploads/
    git commit
    

    然后文件将回到存储库中。

    【讨论】:

    • 但是当我看到提交详细信息时,它们通过 bitbucket 出现,照片仍在以deleted 的形式加载
    • 嗯,也许我误解了你的问题。他们曾经承诺过吗?
    • 假设您至少提交了一次,我已经编辑了答案以反映解决方案。
    猜你喜欢
    • 2020-07-09
    • 2013-06-27
    • 2014-06-11
    • 2012-02-11
    • 2011-10-28
    • 1970-01-01
    • 2010-12-23
    • 2020-12-16
    • 1970-01-01
    相关资源
    最近更新 更多