![](/img/trans.png)
[英]Shouldn't "git pull --rebase --autostash" always pop the stash automatically? Even when there are conflicts?
[英]Where is the temporary stash entry created by `git rebase --autostash`?
我習慣於運行git rebase --autostash
。 由於多種原因(沖突、版本等),我可能會在變基期間被打斷。 我希望在git stash list
的 output 中看到自動存儲的內容。 但事實並非如此。 臨時存儲條目在哪里? 怎么看?
當 rebase 進行時,autostash 存儲在: .git/rebase-merge/autostash
中。
由於此文件存儲在.git/
下,並且是有效的參考文件,因此您可以使用rebase-merge/autostash
作為名稱來指向自動存儲:
git log --oneline --graph rebase-merge/autostash
# you can also use it with 'git stash show' or 'git stash apply' :
git stash show rebase-merge/autostash
git stash apply rebase-merge/autostash
您還可以通過手動調用git update-ref refs/stash
將其“插入”到常規存儲中:
git update-ref -m "autostash" refs/stash rebase-merge/autostash
注意:在閱讀您的問題之前,我還認為自動存儲是常規存儲,我剛剛通過檢查.git/rebase-merge/
的內容發現了上述技巧。
上面的 hack 目前有效(git 版本 2.31),我認為您不應該將它們視為堅如磐石、永遠穩定的功能——例如.git/rebase-merge/
目錄的內部結構不是文檔的一部分。
顯然,如果您從終端運行git rebase
,您還可以在命令的 output 中看到自動存儲的 hash:
$ git rebase -i master
Created autostash: 2acfb51
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.