Export a stash to another computer

You can apply a patch file (without committing the changes yet) by simply running

git apply patchfile

Then you can simply create a new stash from the current working directory:

git stash

You can create stash as patch file from one machine,then can share that patch file to another machines.

Creating the stash as a patch

$ git stash show "stash@{0}" -p > changes.patch

The “stash@{0}” is the ref of the stash.It will create patch file with latest stash. If you want different one use command $ git stash list to see your list of stashes and select which one you want to patch.

Applying the patch

Now transfer that stash to another machine and paste it into the root folder of your project. Then run this command

$ git apply changes.patch

If there is mistake and you want to reverse the change

$ git apply changes.patch --reverse

alternatively you can create a branch from your stash (on computer 1), using

git stash branch stashed_changes_branch

commit your changes:

git commit -a

then add it as a remote on computer 2:

git remote add pc1 user@computer1:/path/to/repo

now you can retrieve the remote information using

git fetch pc1

now you can import the commit in the way you want; using git cherry-pick, git rebase or whatever you like... If you want it to look like you just did git stash apply; you can use git cherry-pick --no-commit.


If you have no direct connection between computer1 and computer2; you can use a remote (like github or something similar):

git push origin stashed_changes_branch

and on computer2:

git fetch