gpt4 book ai didi

git stash 报告 : '' is not a stash reference

转载 作者:IT王子 更新时间:2023-10-29 01:12:55 27 4
gpt4 key购买 nike

不太确定发生了什么,但 git stash 似乎在一个糟糕的地方。

% git stash list
stash@{0}: filter-branch: rewrite
stash@{1}: filter-branch: rewrite
stash@{2}: On mysolr: start mysolr stuff

没问题,git show stash@{0} 工作正常。但是:

% git stash drop
'' is not a stash reference
% git stash pop
'' is not a stash reference
% git stash drop stash@{0}
'stash@{0}' is not a stash reference

我过去经常使用 git stash,但没有遇到过这个。我最近重写了历史记录,以便在发布到 github 之前从历史记录中删除一个文件。我当时运行的命令是

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch FILENAME' \
--prune-empty --tag-name-filter cat -- --all

关于如何修复存储有任何想法吗?

最佳答案

我认为filter-branch打破了你的藏品。如果参数为 git stashstash bag 不够相似,你得到了not a stash reference投诉。

请注意 git show <em>stashref</em>使用普通的旧 git show ,它不要求作为参数给出的提交类似于 stash 。如果git stash show失败的方式与另一个相同git stash命令,或者如果手动检查有问题的存储表明它不再是两父或三父 merge 提交,那么实际上就是这种情况。

可能是 --prune-empty在这里做到了。如果你没有add在 stash 时编辑任何内容,索引提交将为空。一般来说,避免过滤存储引用可能更明智。

您可以尝试两种不同的方法:

  • refs/original/ 恢复原始存储 SHA-1(s) (filter-branch 离开它们的地方)和/或重新登录;用那些重建refs/stash和/或存储引用日志,或者直接使用它们然后破坏存储引用及其引用日志。
  • 仅使用重写的存储中剩余的工作树提交。因为索引提交是空的,所以您真正需要的是一个工作树提交。您可以使用 git show 获取补丁您已经运行的命令。

(有关 stash 和 stash bag 的更多信息,包括与 --all--untracked 一起使用的三亲形式,请参阅 How to recover from “git stash save --all”?。)

假设您已取回内容并希望清除 stash完全引用,这将做到这一点。请注意,这是 "nuke it from orbit"选项——在你确定你已经准备好之前不要这样做:

git update-ref -d refs/stash

关于git stash 报告 : '' is not a stash reference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22076944/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com