【问题标题】:git stash show -p returns fatal errorgit stash show -p 返回致命错误
【发布时间】:2017-01-10 21:04:19
【问题描述】:

当我运行 git stash list 时,我得到以下信息:

stash@{0}: WIP on mybranch: 123456f Generic comment here.
stash@{1}: WIP on mybranch: 234567g Generic comment here.
...
stash@{n}: WIP on mybranch: 345678h Generic comment here.

这是预期的行为。让我感到困惑的是git show 的行为。

当我在我的 repo 中运行 git stash show -p stash@{1} 时,我收到以下错误:

fatal: ambiguous argument 'stash@{1}': unknown revision or path not in working tree.

这怎么可能?我在 git repo 中运行 git stash show -p stash@{1}

【问题讨论】:

  • 这似乎是不可能的。这意味着git rev-parse 无法将stash@{1} 转换为Git 对象ID,而git stash list 仅显示stash 引用的所有引用日志条目,因此如果它显示stash@{1},则stash@{1} 是有效的对象 ID 的名称。 (“在右分支上”部分无关紧要:存储在 no 分支上。)
  • 哪个 Git 版本显示此错误,以及使用哪个 Git 版本创建(克隆)存储库?
  • git version 1.8.0 用于显示错误及其创建的 repo。

标签: git


【解决方案1】:

外壳正在吃掉我自己的花括号。

git stash show -p stash@'{1'} 有效。

具有讽刺意味的是,回答我的问题的答案是@Is it possible to preview stash contents in git? 得到的最少支持。

很奇怪,因为错误报告了带有花括号的命令。你会期望它在没有他们的情况下报告它。

【讨论】:

  • 事实上,我的 shell 也是这样做的,但是错误消息 does 显示它没有大括号:fatal: ambiguous argument 'stash@2': ... 这似乎是不可能的。你在什么操作系统上(为什么你的 Git 这么老?:-) 这些可能有相同的答案......)
猜你喜欢
  • 2014-03-11
  • 2023-02-08
  • 2017-01-13
  • 2014-10-04
  • 1970-01-01
  • 2013-02-10
  • 2015-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多