如果我在输入git stash分支后创建了一个分支会发生什么?

时间:2016-05-28 02:20:54

标签: git

特别是在我输入

之后
git stash branch

我打字

git status

返回了这个:

## HEAD (no branch)
?? Project/Setup_BACKUP_38164.swift
?? Project/Setup_BASE_38164.swift
?? Project/Setup_LOCAL_38164.swift
?? Project/Setup_REMOTE_38164.swift

我现在想要创建一个与我的存储相同的新分支。我想知道我是否打字

git checkout -b *newbranchname

从我目前居住的地方来看,这个新分支是否等于我的藏品?或者我需要做某种提交?如果是这样,为什么需要提交?

谢谢!

2 个答案:

答案 0 :(得分:1)

git stash branch <branchname> [<stash>] Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created, applies the changes recorded in <stash> to the new working tree and index. If that succeeds, and <stash> is a reference of the form stash@{<revision>}, it then drops the <stash>. When no <stash> is given, applies the latest one.

根据文档,git stash branch为您创建并检出分支。在此命令之后,您不必明确签出任何分支

答案 1 :(得分:0)

如果你按照你所说的那样运行你的命令:“git stash branch”你应该得到一个错误或最终出现一个奇怪的情况。首先你可以做到:

git branch

检查你现在在哪个分支,如果你不喜欢这个分支,只需查看感兴趣的分支,然后:

git status

查看您是否有未保存的更改(未提交),从那里您应该可以判断您之前存储的更改是否已应用于当前状态,如果从那里应用了这些更改,则可以创建新分支:

git checkout -b "Name of your new branch" 

你很好。

如果您看不到隐藏的更改,请执行以下操作:

git stash list

并注意标识您感兴趣的更改集的花括号之间的数字,在这种情况下您可以:

git checkout -b "Name of your new branch"
git stash apply {"The Number of stash of interest"}