如何使用自定义消息对未跟踪的文件进行 git stash?

7

如何使用自定义消息执行git stash --include-untracked

我尝试过:

git stash --include-untracked --message "Foo"

git stash --include-untracked "Foo"

但在Git 2.17.1中,这两个命令都会打印出用法警告。

4个回答

5
您要查找的操作是git stash push;在此情况下,您需要使用子命令。因此,您将编写git stash push --include-untracked --message "Foo"

你也可以这样做:git stash push -u -m '在此添加您的消息。'-u 表示包括未跟踪的文件,-m 表示消息。 - Blues Clues

2

在旧版本的git(< 2.13)中,您需要使用save子命令:

git stash save --include-untracked "Foo"

在较新版本中,建议使用push子命令:

git stash push --include-untracked --message "Foo"

注意:自git版本2.16.0起,stash save已被弃用,建议使用stash push

1
我建议为此创建一个分支。
如果你不想让任何人看到这个工作,那就不要将其推送到任何地方。

是的。提交代码,不要藏起来。分支基本上是免费的,可以轻松处理。而且存储在暂存区中的代码是战术上无用的。 - erik258

0

Git 2.7.4

git stash save -u your message here

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接