Git’s branching facilities are awesome. We all know that. However, if you’re like me, I don’t always have the foresight (or discipline I guess) to always create a branch before I dive head first into a refactor. Then I learned about Git’s “stash” command’s ability to create a branch from what you’ve stashed, leaving your current branch untouched. How awesome is that? Check it out:
- Make some changes. Stage them (stash stashes staged changes)
- run “git stash”
- run “git stash branch branchname” where ‘branchname’ is the name of the branch you want to create
And Viola! You know have a branch created from the changes you stashed. You can then use the standard merge facilities to merge that branch back into the one you were working on (or any other branch for that matter).
Isn’t that f’ing cool?
0 Responses to “Nifty Git “Trick””