I always work on branches with Git making small micro commits, then rebase master onto the branch. I keep master shippable and only rebase from
to a 1
master
. I like for my commits to be kept at the top of the topic/feature branch (squashing them if possible).1
topic/feature branch
I’ve recently adopted passing
flag to rebase:1
--ignore-date
1
$(branchA) git rebase master --ignore-date
As a git alias:
1
rid = rebase master --ignore-date
This is great and automatic, but what if something goes wrong?
Make a backup
There are many ways to manage this, and I often push to
branches for an offsite “backup” of my branch. I wanted a way to have a local backup branch.1
origin
Here is a git alias to create a branch with a prefix of
:1
BAK_
1
bak = !git branch `git br | grep '*' | sed -e 's/* /BAK_/'`
Before rebasing, I make a backup copy of the branch in it’s exact state. If the branch is corrupt, I can delete the it and rename the backup to the original.