Once you know the relevant options, it's pretty trivial to roll your
own script/workflow/configuration that suits your own work case. I'll
share how I solve the problem you describe. First, I'd like to mention
git pull --rebase
which is basically
git fetch origin && git rebase @{upstream}
or
git pull --rebase=merges
which is basically
git fetch origin && git rebase --rebase-merges @{upstream}
This does a fetch and afterwards, attempts to rebase any local changes
on top of the remote tracking branch. I'd recommend this approach over
force pushing. It keeps forced history rewrites away from the upstream
repository, which is generally best reserved for "truer" or more
finished work. It also allows for better recovery, in case you mess
up, chances are your history is preserved in the reflog. This can be
configured as the default either globally, per repo or per branch
https://git-scm.com/docs/git-config#Documentation/git-config.txt-pullrebaseBe aware that there are potential situations where this will not
automagically resolve the difference in history in a way that you may
expect and I'd only configure this as default if you feel comfortable
rolling back in case that situation arises. As a starting point, you
can manually initialize the rebase using @{upstream} or @{U}
git fetch
git rebase @{U}If you want to investigate the divergence between a local branch and
its upstream, there are several commands that may be useful depending
on exactly how you want to compare them (often situational in my
experience.) The see which is newer you can run
git show -q --format=fuller HEAD HEAD@{U}
but sometimes you want to know more say, how do the trees differ
git log --online --graph HEAD...HEAD@{U}
or perhaps the difference in contents
git diff HEAD HEAD@{U}
etc. etc.Happy hunting!