git
version control
stash management
remote transfer
developer tools

Export a git stash to another computer (patch, branch or bundle)

Codemia Knowledge Hub ·

A git stash exists only in your local repository, and there is no built-in git stash push origin command. To move stashed work to another computer, export the stash as a patch, turn it into a branch and commit, or bundle that commit for offline transfer.

Option 1: export the stash as a patch

If you only need the changes and not commit metadata, a patch file is the quickest path:

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

This writes the stash's diff to a patch file. Copy the file to the other computer however you like, then apply it inside the target repository:

bash
git apply my-stash.patch

This works well when both repositories are at compatible states, and suits one-off transfers where you do not want extra commits or branches.

Option 2: turn the stash into a branch

For more substantial changes, convert the stash into a normal branch and move that 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 is safer than a raw patch: Git tracks the branch history, you can merge or cherry-pick it later, and conflicts go 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, 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:

bash
git clone stash-transfer.bundle imported-repo

Or, if the target repository already exists:

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

This works well for moving work by USB drive, file share or another offline route.

Which option to 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, a branch is usually the cleanest method, because it stops treating important work as temporary.

What can go wrong

  • Untracked files are missing. If the stash was created without git stash -u, some files never entered the stash, so they will not appear in the exported patch or branch.
  • The patch does not apply. Patch application can fail if the target repository is at a very different commit. A branch-based transfer is easier to recover from because Git has more context for merges.
  • Work left in the stash too long. Stash is for short interruptions, not long-term storage. If the work matters, commit it on a branch.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions