Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to share a stash in git?

I work on a number of machines, and often want to be able to move my current working state from one to another.

I'm looking for a way that I can push/pull a stash from one clone to another, and have it appear either as the stash for the other clone, or as an apparent remote branch. I'm not expecting that the former will necessarily work if the remote already has stash of its own though.

Given that stash is, in effect, already a branch with commits on it (apparently), I'm not looking for solutions along the lines of "commit each stash to a branch and then share those" - I've already got many, many, branches. I'm therefore looking for the refspec or similar that I can use to control the push/pulling.

share|improve this question
up vote 8 down vote accepted

The stash is just stash or refs/stash, which you can push to a remote branch:

git push origin stash@{2}:refs/heads/otherstash

Git will refuse pushing directly to refs/stash, however. Also, there doesn't seem to be a way to push entire reflogs, where previous stashes are stored.

share|improve this answer
git push origin $(for sha in $(git rev-list -g stash); do echo $sha:refs/heads/stash_$sha; done) should do nicely for all stashes; See also – sehe Feb 25 at 15:00

You can make patch and send it to someone. the thing you they have to do is to apply it.

git diff >> file.diff
share|improve this answer

It's not as well integrated as a git push but to avoid creating branches, I use git stash -p or even git diff --cached to create a patch that I git apply on the next machine I work from.

With this solution at least, if many files are altered in your current working state, everything is contained in a single data unit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.