簡體   English   中英

`git rebase --autostash` 創建的臨時存儲條目在哪里?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM