Creating a Branch from the Current Git State

Kris Jenkins, whose wonderful video I’ve written about before, has posted a very handy Magit tip. What do you do if you want to add a feature branch but start working on it before creating the branch? What you’d like to do is move your unpushed work to a new branch and set your current branch back to the state it had before you started working on your changes. Neither of the two common solutions are very good but it turns out that Magit has a solution: magit-branch-spinoff.

It does exactly what you want: it creates a new branch with your unpushed commits and resets your current branch to the last commit it shares with the upstream repository. As far as I can tell, this functionality exists only in Magit and is not part of Git. It’s yet another reason to be using Magit (and, of course, Emacs). Take a look at Jenkins’ post for the details and more background. Also take a look at the documentation to see its full functionality.

This entry was posted in General and tagged , . Bookmark the permalink.