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?

  • Maybe you can view the stash, and save it to a file? – suvayu Sep 20 '15 at 16:44
  • @suvayu I have already tried that, it wont work – ChillarAnand Sep 21 '15 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 '15 at 9:55
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.

  • "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 '15 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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