git
version control
stash management
remote transfer
developer tools

Export a stash to another computer

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

git stash is designed as a local convenience, not as a transport mechanism between machines. A stash is stored only in the local repository, so there is no built-in git stash push origin command. To move stashed work to another computer, the practical options are turning the stash into a patch, turning it into a branch and commit, or bundling that commit for transfer.

Option 1: export the stash as a patch

If you just want the changes and do not need full commit metadata, a patch file is often the quickest path.

bash
git stash list
git stash show -p stash@{0} > my-stash.patch

That writes the diff from the stash into a patch file. Transfer the file to the other computer however you like, then apply it inside the target repository.

bash
git apply my-stash.patch

This method is simple and works well when both repositories are at compatible states. It is especially useful for one-off transfers where you do not want to create extra commits or branches.

Option 2: turn the stash into a branch

If the changes are more substantial, the better solution is usually to convert the stash into a normal Git branch and move that branch instead.

bash
1git stash branch stash-transfer stash@{0}
2git add .
3git commit -m "Transfer stashed work"
4git push origin stash-transfer

On the other computer:

bash
git fetch origin
git checkout stash-transfer

This approach is safer than a raw patch because Git can track the branch history, you can merge or cherry-pick it later, and conflicts are handled through standard Git workflows instead of plain patch application.

Option 3: use git bundle when there is no shared remote

If the machines cannot share a remote repository, create a temporary commit and export it as a bundle.

bash
1git stash branch stash-transfer stash@{0}
2git add .
3git commit -m "Transfer stashed work"
4git bundle create stash-transfer.bundle HEAD

Copy stash-transfer.bundle to the other computer and import it there:

bash
git clone stash-transfer.bundle imported-repo

Or, if you already have the target repository:

bash
git fetch /path/to/stash-transfer.bundle HEAD:stash-transfer
git checkout stash-transfer

This works well when you are moving work by USB drive, file share, or some other offline mechanism.

Which option should you choose

Use a patch when:

  • The change is small
  • You only need the diff
  • You do not care about preserving a branch or commit history

Use a temporary branch when:

  • The stash is meaningful work
  • You have a remote between the machines
  • You want Git to manage history and conflicts normally

Use a bundle when:

  • There is no shared remote
  • You still want Git-native transfer instead of a raw patch

In practice, turning the stash into a branch is usually the cleanest method because it stops treating important work like something temporary.

Common Pitfalls

The most common mistake is assuming git stash itself is portable. It is not. The stash lives only in the local repository until you turn it into something transferable.

Another issue is forgetting untracked files. If the original stash was created without git stash -u, some files may never have entered the stash at all, so they will not appear in the exported patch or branch.

Patch application can also fail if the target repository is at a very different commit. In that case, a branch-based transfer is usually easier to recover from because Git has more context for merges.

Finally, do not leave critical work in stash for too long. If the work matters, commit it on a branch. Stash is best for short-lived interruptions, not long-term storage.

Summary

  • A stash is local-only, so it cannot be sent directly to another computer.
  • 'git stash show -p lets you export a stash as a patch file.'
  • 'git stash branch is usually the cleanest way to turn a stash into transferable Git history.'
  • 'git bundle is useful when the two machines do not share a remote.'
  • If the work matters, prefer a branch and commit over keeping it in stash.

Course illustration
Course illustration

All Rights Reserved.