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:
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:
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:
On the other computer:
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:
Copy stash-transfer.bundle to the other computer and import it:
Or, if the target repository already exists:
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.
Related reading
- Failed to pull image pull access denied , repository does not exist or may require ''docker login''
- Fast-forward merge is not possible. To merge this request, first rebase locally
- fatal early EOF fatal index-pack failed
- fatal Not a git repository or any of the parent directories .git
- fatal Not a valid object name 'master
- fatal The current branch master has no upstream branch
- fatal unable to access 'https//gitlab-ci-tokenMASKEDgitlab.mydomain.com/xxx.git/' SSL certificate problem unable to get issuer certificate
- Fetch from origin with deleted remote branches
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseInterview Questions practice on Codemia
Over 11,000 interview practice questions for 300+ companies, searchable by company and role.