我为将来保存了一个存储,我想给一个有意义的名字。虽然可以将消息作为参数传递给git stash save
,但有没有办法将消息添加到现有存储中?
5 回答
您可以直接编辑存储在.git/logs/refs/stash
.
我知道这可能并不理想,但无论如何应该可以。
是的,有一种方法,你可以试试这个:
git stash store -m "your descriptive message here" stash@{1}
这将创建一个以stash@{0}
上述消息命名的新 Stash。
这个 Stash 与stash@{1}
.
然后您可以删除上面的旧 stash@{1}:
git stash drop stash@{2}
# stash@{1} 已成为 stash@{2},因为已创建新的 stash。
注意:您不能使用 stash@{0} 执行此操作:git stash store -m "message here" stash@{0}
不会执行任何操作。
(扩展 manojlds 的答案。)附加消息最简单的方法确实是取消存储并重新存储消息,有一个git stash branch
命令可以帮助您执行此操作。
git stash branch tmp-add-stash-message
git stash save "Your stash message"
唯一的缺点是这个存储现在似乎来自tmp-add-stash-message
分支。之后,您可以签出另一个分支并删除这个临时分支。
当然,这假设您的工作副本是干净的,否则您可以隐藏当前的更改 :-)
并非没有弹出并再次保存。
正如@manojlds 建议的那样,这里有一些命令可以帮助您再次弹出和保存:
git stash #save what you have uncommitted to stash@{0}
git stash pop stash@{1} #or another <stash> you want to change the message on
# only if necessary, fix up any conflicts, git reset, and git stash drop stash@{1}
git stash save "new message"
git pop stash@{1} #get back to where you were if you had uncommitted changes to begin with