As explained on Don't Be Scared of git rebase, git fetch+rebase
is a better alternative to git pull
; unfortunately it's not as concise.
From now on, use git get
instead of git pull
, a custom command that does this:
# get data from remote
git fetch origin
# rebase the remote branch with the same name as local
git rebase origin/$(git rev-parse --abbrev-ref HEAD)
Set it up by running this command:
git config --global alias.get '!git fetch origin && git rebase origin/$(git rev-parse --abbrev-ref HEAD)'
If you're ready to push, simply run git put
. It will run the above + git push
. To set it up, run this:
git config --global alias.put '!git fetch origin && git rebase origin/$(git rev-parse --abbrev-ref HEAD) && git push origin HEAD'
Thank you so much. This saves me a lot of time!