git stash save 和 git stash push 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44680028/
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
What's the difference between git stash save and git stash push?
提问by David Burson
When should I use git stash save
instead of git stash push
and vice-versa?
我什么时候应该使用git stash save
而不是,git stash push
反之亦然?
采纳答案by phd
git stash save
accepts a single non-option argument — the stash message.
git stash save
接受一个非选项参数——存储消息。
git stash push
accepts the message with option -m
and accepts a list of files to stash as arguments.
git stash push
接受带有选项的消息-m
并接受要作为参数存储的文件列表。
回答by VonC
Just to be clear, starting Git 2.15/2.16 (Q1 2018), git stash save
has been deprecated in favour of git stash push
(though git stash save
is still available for the time being).
需要明确的是,从 Git 2.15/2.16(2018 年第一季度)开始,git stash save
已被弃用git stash push
(尽管git stash save
目前仍然可用)。
See commit c0c0c82, commit fd2ebf1, commit db37745(22 Oct 2017) by Thomas Gummerer (tgummerer
).
(Merged by Junio C Hamano -- gitster
--in commit 40f1293, 06 Nov 2017)
请参阅Thomas Gummerer ( ) 的commit c0c0c82、commit fd2ebf1、commit db37745(2017 年 10 月 22 日)。(由Junio C Hamano合并-- --在commit 40f1293,2017 年 11 月 6 日)tgummerer
gitster
stash
: mark "git stash save
" deprecated in the man page'
git stash push
' fixes a historical wart in the interface of 'git stash save
'.
As 'git stash push
' has all functionality of 'git stash save
', with a nicer, more consistent user interface deprecate 'git stash save
'.
stash
: remove now superfluos help for "stash push
"With the '
git stash save
' interface, it was easily possible for users to try to add a message which would start with "-
", which 'git stash save
' would interpret as a command line argument, and fail.
For this case we added some extra help on how to create a stash with a message starting with "-
".For '
stash push
', messages are passed with the-m
flag, avoiding this potential pitfall.
Now only pathspecs starting with "-
" would have to be distinguished from command line parameters by using "-- --<pathspec>
".
This is fairly common in the git command line interface, and we don't try to guess what the users wanted in the other cases.Because this way of passing pathspecs is quite common in other git commands, and we don't provide any extra help there, do the same in the error message for '
git stash push
'.
stash
:git stash save
在手册页中不推荐使用标记“ ”“
git stash push
”修复了“git stash save
”界面中的历史疣。
由于“git stash push
”具有“ ”的所有功能git stash save
,因此具有更好、更一致的用户界面,因此不推荐使用“git stash save
”。
stash
: 删除现在对 "stash push
" 的多余帮助使用“
git stash save
”界面,用户很容易尝试添加以“-
”开头的消息,“ ”git stash save
会将其解释为命令行参数,但失败了。
对于这种情况,我们添加了一些关于如何使用以“-
”开头的消息创建存储的额外帮助。对于“
stash push
”,消息与-m
标志一起传递,避免了这种潜在的陷阱。
现在,只有以“-
”开头的路径规范才能通过使用“-- --<pathspec>
”与命令行参数区分开来。
这在 git 命令行界面中很常见,我们不会尝试猜测用户在其他情况下想要什么。因为这种传递路径规范的方式在其他 git 命令中很常见,我们不提供任何额外的帮助,请在“
git stash push
”的错误消息中执行相同的操作。
With Git 2.18 (Q2 2018), the command line completion (in contrib/
) has been taught that "git stash save
" has been deprecated ("git stash push
" is the preferred spelling in the new world) and does not offer it as a possible
completion candidate when "git stash push
" can be.
在 Git 2.18(2018 年第 2 季度)中,命令行补全 (in contrib/
) 已被教导“ git stash save
” 已被弃用(“ git stash push
” 是新世界中的首选拼写),并且在“ git stash push
” 可以时不提供它作为可能的补全候选是。
See commit df70b19, commit 0eb5a4f(19 Apr 2018) by Thomas Gummerer (tgummerer
).
(Merged by Junio C Hamano -- gitster
--in commit 79d92b1, 08 May 2018)
请参阅Thomas Gummerer ( ) 的commit df70b19和commit 0eb5a4f(2018 年 4 月 19 日)。(由Junio C Hamano合并-- --在commit 79d92b1,2018 年 5 月 8 日)tgummerer
gitster
completion
: makestash -p
and alias forstash push -p
We define '
git stash -p
' as an alias for 'git stash push -p
' in the manpage. Do the same in the completion script, so all options that can be given to 'git stash push
' are being completed when the user is using 'git stash -p --<tab>
'.
Currently the only additional option the user will get is '--message
', but there may be more in the future.
completion
: makestash -p
和别名stash push -p
我们在联机帮助页中将“
git stash -p
”定义为“ ”的别名git stash push -p
。在完成脚本中执行相同操作,以便git stash push
在用户使用“git stash -p --<tab>
”时完成可以提供给“ ”的所有选项。
目前,用户将获得的唯一附加选项是“--message
”,但将来可能会有更多选项。