Testorossa
Testorossa

Reputation: 15

git from checked-out stash to branch

I want 100% of stash 4aa0f82 below on my master branch

Problem is, stash apply/pop does not apply all the changes. I can resolve some conflicts, but some important stuff that I changed and saved in the stash does not appear in the conflicts (maybe because there was a commit with a detached HEAD in between).

I want 100% of the stash on my branch. it is all there when I do checkout stash@{0}. how do I move that full stashed commit on my branch?

git log --graph --decorate --oneline stash output:

*-.   6872ac5 (refs/stash) WIP on (no branch): d5da51e
|\ \
| | * 52db257 untracked files on (no branch): d5da51e
| * fb1c947 index on (no branch): d5da51e
|/
*   d5da51e bug removed
|\
| * 3096570 index on master: 89f11dd
|/
* 89f11dd (HEAD, master)

git log --graph --decorate --oneline output:

*   4aa0f82 (HEAD)
|\
| * bb34a5b index on HEAD: d5da51e
|/
*   d5da51e
|\
| * 3096570 index on master: 89f11dd
|/
* 89f11dd (master)

Upvotes: 1

Views: 134

Answers (1)

jthill
jthill

Reputation: 60255

4aa0f82 isn't a stash commit, or not anymore it isn't, anyway. It looks like you've been doing your work on checked-out stash commits, regardless, the easiest way to get where you want from here, if I understand this correctly, is going to be

# if you want all the changes from master through 4aa0f82 (i.e. also the d5da51e work)
git checkout master
git merge --squash 4aa0f82   # HEAD@{1}, "where HEAD was 1 checkout ago" works too

# if you want just the 4aa0f82 changes, not the d5da51e ones:
git checkout master
git cherry-pick --no-commit 4aa0f82   # edit: might need `bb34a5b` here instead
git commit

but I'm pretty sure it's the first set you want, with the d5da51e changes.

Upvotes: 1

Related Questions