Skip to main content
Tim's (still) not blogging

git snapshotting before rollback

I had a bunch of uncommitted in-progress changes that I didn’t like, wanted to rip out, but still wanted a snapshot of what I had in case I wanted to come back to it later.

Make a new branch

Checkout that new branch

Add any untracked new files

Commit

git reset --soft HEAD^

Checkout previous branch

Now I’m back where I started (with those new files still added to the index), with a bunch of uncommitted changes, and I have a committed branch with all these changes and additions if I want to refer to them again later.