Last Updated: February 25, 2016
·
687
· lxe

Remotely Stash Git Commits

Let's say you're in the middle of working on some code, and you need to stop working immediately.

You don't want to make a half-finished commit, and you can't stash, because you would like to resume your work on a different machine.

Here's what I do to "stash" a draft commit or a series of commits remotely:

# Doing some work
# ...
# Gotta head out! Force everything into the remote origin/draft branch
git commit -am "draft: in the middle of a refactor"
git push origin +master:draft

Then, from a different workstation:

git pull upstream draft && git reset HEAD~1

Now my draft commit is pulled in, and unstaged allowing me to continue my work and then make nice commit(s) once I've reached a logical conclusion.

1 Response
Add your response

Cool !!!

over 1 year ago ·