【问题标题】:GIT: unapply a stash - too many revisions specifiedGIT:取消应用存储 - 指定的修订太多
【发布时间】:2018-08-19 17:08:56
【问题描述】:

如果解决方案是微不足道的,我很抱歉,但我不是 GIT 专家,我在互联网上没有找到任何东西。

我隐藏了一些更改,但我很难恢复它们。也许我发送了两次git stash 命令,我希望这不会让我失去一切。

根据this questionofficial documentation,我尝试了以下命令:

git stash pop

我收到了:

src/schema/schema-generator2.js: needs merge
unable to refresh index

所以我尝试了:

git merge
error: Merging is not possible because you have unmerged files

然后我尝试了:

git stash apply stash@{0}
unknown option: -encodedCommand
git stash apply
src/schema/schema-generator2.js: needs merge
git stash apply --index
src/schema/schema-generator2.js: needs merge
git stash show -p stash@{0} | git apply -R
git : Too many revisions specified: 'stash@' 'MAA=' 'xml' 'xml'
In riga:1 car:1
+ git stash show -p stash@{0} | git apply -R
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Too many revisi...A=' 'xml' 'xml':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
error: unrecognized input

在上面的文本中,我将消息编写为代码,并引用了答案。我希望它很清楚。

我不明白发生了什么,为什么没有任何效果?我可以做些什么来取消隐藏我的更改?

【问题讨论】:

  • 你能把git status命令的输出贴出来
  • 你忘了提到你使用 PowerShell 作为 shell。在本例中,{ 是 PowerShell 的特殊字符。
  • @PetSerAl 你是对的,我正在使用 VS Code,当我使用终端时,许多错误停止出现。
  • 顺便说一句,我解决了这个问题,即使我无法解释如何。可能这只是 VS Code 的问题,重新启动它就足够了

标签: git git-stash


【解决方案1】:

看起来问题在于分支的隐藏更改和最新 HEAD 不会自动合并,特别是在 src/schema/schema-generator2.js 文件中

这意味着您必须手动解决合并冲突

最好的方法是将隐藏的更改转换为补丁文件并尝试应用补丁文件。您仍然会看到合并冲突,但可以更好地控制解决更改

$ git stash show -p --color=never > my-stashed-changes.patch
# This should show the same merge error
$ git apply my-stashed-changes.patch
# modify the patch file to resolve conflicts and apply again

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-06
    • 2014-09-13
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    相关资源
    最近更新 更多