git fresh
In codebases that use Git, a common development strategy is to have a separate feature branch for a feature, push that to GitHub (or whatever equivalent you use) and then switch back to master, update, and start working on the next feature.
I found myself doing that pretty often, so I wrote a simple git alias
that does all that in one step. I call it git fresh
.
$ git config --global alias.fresh \
'!git checkout master && git fetch origin master && GIT_SEQUENCE_EDITOR=: git rebase -i origin/master'
What this does is checks out master
, fetches the latest and rebases your local to be at the head. The GIT_SEQUENCE_EDITOR=:
step is to prevent rebase --interactive
from starting up an editor (which would just have shown noop
because you do all your development on feature branches… right?).
git config --global alias.fresh
simply adds the alias to your ~/.gitconfig
file.