Skip to main content
Select a theme to activate music mode, and use your keyboard to play a tune.

gcn! — Quickly adding staged changes to previous commit

Love it or hate it, rebasing is a part of git. I'm a true believer and — as such — find myself rebasing constantly.

Quite often I find myself wanting to add the change I've just made to my previous commit, and up to now I've always committed the change, started a rebase, and squashed my commit into the previous commit.

Recently I discovered that I've been a fool, and that there's a much simpler way to do it.

git commit -v --no-edit --amend

That will grab your staged changes and plonk them into your previous commit; no rebasing necessary! If you're a fellow Oh My Zsh user, then it's as simple as running:

gcn!

I should probably have learnt this a decade ago.