git config --global push.default current
git config --global merge.defaultToUpstream true
git config --global branch.autosetupmerge true
git config --global branch.autosetuprebase remote
git config --global alias.cb 'checkout -b'
git config --global alias.ps 'push -u'
git config --global alias.pl '!git fetch -p && git rebase'
$ git cb new_branch
Switched to a new branch 'new_branch'
$ git ps
Branch new_branch set up to track remote branch new_branch from origin by rebasing.
Everything up-to-date
$ git pl
Current branch new_branch is up to date.
If you want it really straightforward, run this once:
git config --global alias.sync '!git fetch -p && git rebase && git push -u'
and use it on your branches like this:
$ git sync
- Git will display
Branch new_branch … by rebasing.
every time you push; it won't hurt anything. - If you work with multiple remotes (for instance, via Heroku),
git ps heroku
will set the default remote (and hence, rebase target) for your branch to Heroku (almost certainly not what you want).