How can I format patch with what I stash away

silverburgh picture silverburgh · Jan 29, 2010 · Viewed 46.9k times · Source

In git, I stash away my changes. Is it possible that I can create a patch with what I stash away? And then apply that patch in some other repository (my co-worker's)?

I know git format-patch -1, but I think that it's for what I have committed. But I am looking for the same thing for changes that I stashed away.

And how can I apply a patch in other repository?

Answer

Greg Hewgill picture Greg Hewgill · Jan 29, 2010

Sure, git stash show supports this:

git stash show -p

So, use

git stash list

to find out the number of the stash that you want to export as a patch, then

git stash show -p stash@{<number>} > <name>.patch

to export it.

For example:

git stash show -p stash@{3} > third_stash.patch