Skip to Main Content
TWIL
git
Emily presents a TWIL session featuring a tutorial on Git aliases and the Dash documentation tool in a software development context.

Dive into our latest TWIL installment, where Cuttlesoft delves into the ever-evolving world of software development with our adept Emily. This week, journey through the intricacies of Git with her enlightening piece on a Git alias for moving commits to a new branch, a must-have for streamlining your version control process. As a double feature, Emily also revives the utility of Dash, a robust documentation browser that ensures your coding flow remains uninterrupted, even when the grid can't keep up. Join us for this micro-learning session that promises to enrich your software development toolkit.

Git alias for moving commits to a new branch

Whether you accidentally commit directly to master or need to cherrypick commits due to branching off another branch, moving a series of commits to a new branch off of master is super helpful.

mt is short for "move to", which helped me remember the order of the arguments.

It will:

# gitconfig

[alias]
    mt = "!f() { git checkout origin/master && git checkout -b $2 && git cherry-pick $1 && git checkout master && git reset origin/master --hard && git checkout $2; }; f"

Usage

Say you accidentally made two commits on master and your log looks something like this:

* 678 - (HEAD -> master) [CUTL-001] ☔️ Tests for feature that should be on a branch
* 345 - [CUTL-001] ✨ Feature that should be on a branch
* 012 - (origin/master) [CUTL-001] ✨ Latest thing on master

You can run:

git mt 345^..678 feature/new-thing

I read this in my head as: "Move commits 345 thru 678 to a branch named feature/new-thing"

You could also add an argument to control which branch you want the new branch to branch off of, but I find that this is nearly always master for me.

  • git
Emily Morehouse's profile picture
Emily Morehouse

Cofounder, Director of Engineering


Dash

I used Dash years ago and am super happy to find that it's better than ever.

It's great for traveling or other situations where you may need to reference docs but don't have internet, as it lets you store docsets locally. I also like having a hotkey that immediately opens up the docs window. It also has great support for searching by class or method name, and has a nice explorer for class/method breakdowns.

  • Tools
Emily Morehouse's profile picture
Emily Morehouse

Cofounder, Director of Engineering

Related Posts

Digital pioneer journeying through technological quirks, reminiscent of vast waterfalls and rocky terrains
April 5, 2017 • Kyle Misencik

Infinitely dispatching actions + React, Redux & React Router v4

While implementing JWT for an application, we ran into a quirk with React Router v4. Here, we hope to show how to implement protected client-side routes while avoiding some of the pitfalls we encountered.

Turtle swimming close to a life preserver as a metaphor for developers using Git version management to stay afloat
May 4, 2017 • Nick Farrell

Life-Saving Git Tips

From salvaging lost commits to streamlining your workflow, discover how to make your coding life smoother and avoid common pitfalls.