更改 Git 存储消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8124411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Git stash message
提问by CharlesB
I have a stash saved for the future that I want to give a meaningful name. While it's possible to pass a message as argument to git stash save
, is there a way to add a message to an existing stash?
我有一个为将来保存的藏匿处,我想给它一个有意义的名字。虽然可以将消息作为参数传递给git stash save
,但有没有办法将消息添加到现有存储中?
采纳答案by yibe
You can directly edit the messages stored in .git/logs/refs/stash
.
您可以直接编辑存储在 中的消息.git/logs/refs/stash
。
I know it's probably not ideal, but should work anyway.
我知道这可能并不理想,但无论如何都应该有效。
回答by Ryan Le
Yep, there is a way, you can try this:
是的,有一种方法,你可以试试这个:
git stash store -m "your descriptive message here" stash@{1}
git stash store -m "your descriptive message here" stash@{1}
This will create a new Stash named stash@{0}
with the message as above.
This Stash is same as stash@{1}
.
这将创建一个stash@{0}
以上述消息命名的新 Stash 。
此 Stash 与stash@{1}
.
Then you can remove the old stash@{1} above with:
然后您可以使用以下命令删除旧的 stash@{1}:
git stash drop stash@{2}
# the stash@{1} has become stash@{2} as a new stash has been created.
git stash drop stash@{2}
# stash@{1} 已成为 stash@{2},因为新的 stash 已被创建。
NOTE: you cannot do this with stash@{0}: git stash store -m "message here" stash@{0}
will do nothing.
注意:您不能使用 stash@{0} 执行此操作:git stash store -m "message here" stash@{0}
将不执行任何操作。
回答by manojlds
Not without popping and saving again.
不是没有弹出并再次保存。
回答by krlmlr
(Expanding on manojlds's answer.) The simplest thing to attach a message is indeed to un-stash and re-stash with a message, there is a git stash branch
command that will help you doing this.
(扩展 manojlds 的答案。)附加消息的最简单的事情确实是取消存储并重新存储消息,有一个git stash branch
命令可以帮助您执行此操作。
git stash branch tmp-add-stash-message
git stash save "Your stash message"
The only drawback is that this stash now appears to originate from the tmp-add-stash-message
branch. Afterwards, you can checkout another branch and delete this temporary branch.
唯一的缺点是这个藏匿处现在似乎来自tmp-add-stash-message
分支。之后,您可以检出另一个分支并删除此临时分支。
Of course, this assumes that your working copy is clean, otherwise you can stash the current changes :-)
当然,这假设您的工作副本是干净的,否则您可以隐藏当前的更改:-)
回答by Jayen
Here's some commands to help you pop and save again as @manojlds suggests:
这里有一些命令可以帮助您按照@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