How can I share a git stash?

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.


It's not as well integrated as a git push but to avoid creating branches, I use git stash show -p > change.patch (after stashing the changes) or even git diff --cached > change.patch to create a patch that I git apply change.patch 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.


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

git diff >> file.diff

Tags:

Git