Working on some code and want to save a portion of it for later. Assuming not much will happen between the two changesets I decide to git stash -p
. An hour or so later realize that it'll get hairy, and don't want to loose my stash. So I want to create a branch out of it.
Unfortunately doing a simple
git branch stash-branch stash@{0}
doesn't yield the results I want. Looking at the tree I see
* 99b0d0c (refs/stash, stash-branch) WIP on my-dev-branch: 2af1f8b PARTIAL but it builds again!
|\
| * d45ddae index on my-dev-branch: 2af1f8b PARTIAL but it builds again!
|/
* 2af1f8b (HEAD -> my-dev-branch) PARTIAL but it builds again!
| * d8bb99f (origin/my-dev-branch) PARTIAL but it builds again!
|/
* fe1296d PARTIAL (doesn't compile)
What I expected is for stash-branch
to be on d45ddae
, but didn't work out that way. Oh well, I'll go looking around for another way to do this automatically.
After a bit of searching, can't find anything. So my question: Is there an automatic way to refer to the commit just before the tip of stash@{N}
? All my efforts result in the newly made branch pointing at my-dev-branch
.
EDIT: The git branch
command above was incorrect. Has been corrected.
Also, as far as I can tell git stash branch
always automatically checks out the branch. In this case I'd only like to create a new branch at an existing sha.
Basically, I'm want to create a new branch, without checking it out, at d45ddae
.