【问题标题】:Still do not understand how to recover and perform a "git reset HEAD"仍然不明白如何恢复和执行“git reset HEAD”
【发布时间】:2013-03-06 21:11:55
【问题描述】:

我在尝试将我的应用提交到 Git 时收到以下消息:

**The working copy "XYZ" failed to commit files.**
fatal: Repository has been updated, but unable to write
new_index file. Check that disk is not full or quota is
not exceeded, and then "git reset HEAD" to recover.

我一直在尝试了解如何从中恢复并执行“git reset HEAD”而不丢弃任何已提交的内容。我已阅读有关终端命令并尝试过但仍然不明白要采取的步骤。

磁盘未满,但它位于我网络上的 Qnap NAS 上。

有人可以给我一份分步指南或指点我吗?

【问题讨论】:

    标签: git xcode4.5 ios6.1


    【解决方案1】:

    git reset HEAD 不会改变你的工作树或提交历史,它只会改变索引。因此,您不必担心丢失工作树中的实际文件。您只需要确保,当您准备好再次尝试提交时,将所有内容添加到应该存在的索引中,例如使用git commit -a 或显式使用git add (但是您上次提交下一个提交,您可以再次这样做。)

    【讨论】:

      【解决方案2】:

      我会使用 git 存储。首先存储您无法提交的工作,重置以恢复,然后取消存储您的工作并重新提交。

      git stash
      git reset HEAD
      git stash show -p | git apply -R
      git commit -am "new commit"
      

      【讨论】:

      • 谢谢 Maher,我应该在与我的应用程序相同的目录中执行此操作吗?
      • Maher,我得到 -bash: git: command not found in the directory was found and in the app is the app驻留和/Applications/Xcode.app/Contents/Developer/usr/bin
      • 你通常使用命令行提交吗?如果是,则应用该位置的命令。
      • 哦,我明白了!如果你在终端中只输入 git,你会得到什么?如果找不到命令。尝试在你的 mac 中安装 git:git-scm.com
      猜你喜欢
      • 1970-01-01
      • 2022-11-30
      • 2013-01-17
      • 2021-05-14
      • 2021-07-04
      • 2011-08-19
      • 2016-02-24
      • 2023-03-23
      相关资源
      最近更新 更多