2011-11-14 124 views
55

我有一個藏匿的未來,我想給一個有意義的名字。雖然可以將消息作爲參數傳遞給git stash save,但是有沒有方法將消息添加到現有的存儲?更改Git存儲消息

+0

我認識到這個問題比被標記的副本要舊,但是這個問題有更好的答案。 – Michael

回答

45

您可以直接編輯存儲在.git/logs/refs/stash中的消息。

我知道這可能不理想,但應該無論如何工作。

+5

這似乎工作的事實是非常幸運的:消息也存儲在提交消息中(存儲在內部表示爲提交),並且你當然不會改變那。 – Cascabel

+0

它確實有效;非常感謝 – CharlesB

+2

這實際上並沒有改變提交信息(參見'git show stash'或'git log --all'),只有存儲reflog中的條目。 – Zaz

15

不是沒有彈出並再次保存。

+2

雖然看起來不雅,但這是最簡單的解決方案 – Kirby

+1

如果你的存儲在各個分支上,那麼「彈出並再次保存」會將存儲的提交應用於當前分支(這可能會導致合併失敗)並非如此簡單。如果你發現自己有一長串窗扇,你可能需要更好地利用分支。 – i3ensays

+1

起初,我以爲他說,「不是沒有pooping」 –

11

(在manojlds的回答中進行了擴展。)附加消息最簡單的事情的確是將消息取消隱藏並重新存儲,但有一個git stash branch命令可以幫助您執行此操作。

git stash branch tmp-add-stash-message 
git stash save "Your stash message" 

唯一的缺點是,這個藏匿現在看來從tmp-add-stash-message分支發起。之後,您可以簽出另一個分支並刪除此臨時分支。

當然,這裏假設你的工作副本是乾淨的,否則你可以藏匿的電流變化:-)

+0

這個回答實際上是正確的 – woohoo

1

這裏的一些命令來幫助你彈出,再次保存爲@manojlds提示:

git stash #save what you have uncommitted to [email protected]{0} 
git stash pop [email protected]{1} #or another <stash> you want to change the message on 
# only if necessary, fix up any conflicts, git reset, and git stash drop [email protected]{1} 
git stash save "new message" 
git pop [email protected]{1} #get back to where you were if you had uncommitted changes to begin with 
9

是的,有一種方法,你可以試試這個:

git stash store -m "your descriptive message here" [email protected]{1}

這將創建一個名爲[email protected]{0}的新Stash,並帶有上述消息。
該隱藏與[email protected]{1}相同。

然後你就可以刪除{1}以上的老藏@:

git stash drop [email protected]{2}#藏匿@ {1}已經成爲藏匿@ {2}作爲新的存儲已創建。

注意:您不能使用存儲@ {0}來執行此操作:git stash store -m "message here" [email protected]{0}將不會執行任何操作。

+1

爲什麼它不能和'stash {0}'一起使用? – CharlesB

+0

其實我不知道,我試過了,但沒有奏效。所以我猜測: 如果這樣調用了stash @ {1},那麼它會將一個stash @ {1}的副本帶到棧頂,所以當用戶調用'git stash apply'時,他會得到不同的結果。 如果這樣調用存儲@ {0},稍後調用'git stash apply'會產生相同的結果。 –

+0

有'git stash保存'你的消息'' – woohoo