1

I am trying to export one repository stash to another.

In terminal I can do

git stash show -p > temp.patch

But when in magit buffer, if I run z it is not showing any switch for -p before or after s. So, how can I export stash using magit?

3
  • Maybe you can view the stash, and save it to a file?
    – suvayu
    Sep 20, 2015 at 16:44
  • @suvayu I have already tried that, it wont work Sep 21, 2015 at 5:04
  • I see that the diff file headers are non-standard, and applying fails. Maybe this is worth a feature request: show stashes with standard diff formatting (as is done for regular commits).
    – suvayu
    Sep 21, 2015 at 9:55

1 Answer 1

2

I have added a wrapper for git stash show -p <stash> > patch. It's available from the stash popup now (z f).

But note that a stash commit consists of two or three commits, and that one of these commits is a merge commit. What this command does, is to save the diff for stash@{N}^..stash@{N} to a file. The intermediate index (stash@{N}^2) is lost, and if the work tree commit does not only "adds" additional changes, but instead further "changes" the changes in the index commit, then those changes in the index are completely lost.

In the comments it was suggested that it should be possible to apply the individual commits that make up the stash as presented in the stash buffer, but that wasn't the case because the wrong section type was used. I have changed the section type to commit, but that doesn't make it possible to create a patch from the worktree commit, because that is a merge commit and no patches can be created from merge commits.

1
  • "if the work tree commit does not only "adds" additional changes, but instead further "changes" the changes in the index commit" - Could you explain what that means in terms of user actions? i.e. under what circumstances would such a stash be created?
    – npostavs
    Oct 2, 2015 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.