Reputation: 1044
Specially, after I typed
git stash branch
I typed
git status
which returned this:
## HEAD (no branch)
?? Project/Setup_BACKUP_38164.swift
?? Project/Setup_BASE_38164.swift
?? Project/Setup_LOCAL_38164.swift
?? Project/Setup_REMOTE_38164.swift
I now want to create a new branch that is the same as my stash. I'm wondering if I type
git checkout -b *newbranchname
From where I currently am in HOME, will this new branch be equal to my stash? Or would I need to do a commit of some sort? Why is the commit necessary if so?
Thanks!
Upvotes: 0
Views: 64
Reputation: 564
If you run your command as you said: "git stash branch" you should have gotten an error or end up with a strange situation. First you can do:
git branch
to check in which branch you are right now, if you don't like this branch just checkout the one of interest, then:
git status
to see if you have unsaved changes (not committed), from there you should be able to tell if your previously stashed changes are applied or not in your current status, if they are applied from there you can create your new branch:
git checkout -b "Name of your new branch"
and you are good.
If you can't see your stashed changes then do:
git stash list
and notice the number between curly braces that identify the set of changes you are interested on, in this case you do:
git checkout -b "Name of your new branch"
git stash apply {"The Number of stash of interest"}
Upvotes: 0
Reputation: 589
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.
As per the docs, git stash branch creates and checks out the branch for you. After this command you don't have to explicitly checkout any branch
Upvotes: 1