使用git stash branch命令时未找到暂存内容

4

使用git,我正在主分支上工作,并有一些未添加和未提交的文件。我不想将它们添加或提交到主分支上。相反,我正在尝试将这些文件藏起来并移动到一个新的分支上,在那里添加并提交它们。然而,这个过程失败了,出现了错误消息:“找不到存储”。请参见下面的日志:

$git status

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   Makefile
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   newfile.c
no changes added to commit (use "git add" and/or "git commit -a")

当我尝试使用git stash时

$git stash branch mywork
No stash found.

我相信以前我使用过类似的方式来运用git stash,但我不知道为什么现在它失败了。怎样把我的更改暂存到另一个分支并提交它们?

1个回答

7
< p > git stash branch 命令从已存在的暂存区创建一个新分支。因为您还没有现有的暂存区,所以会出现错误消息。

只需使用git stash, 然后如果您想从此暂存区创建新分支,使用git stash branch mywork


1
非常感谢您的快速回复。 - MaACAn

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