Using git-stash with a branch

You’re working on something on master but you want your changes to be transfered to a branch

Do this:

[17:44:40][akadri@kryptonite:~/Projects/myproject]$ git stash save "message"
Saved working directory and index state On master: stash message
HEAD is now at 821a965 commit message

You can list your stash with:

[17:48:09][akadri@kryptonite:~/Projects/myproject]$ git stash list
stash@{0}: On master: stash message

Now you transfer your changes to a new branch of your choosing and checkout that branch with:

[17:51:54][akadri@kryptonite:~/Projects/Wikipedia]$ git stash branch mybranch stash@{0}
Switched to a new branch 'mybranch'

That’s it!