I aim to minimise commits on each merge request. To achieve this I rebase locally before pushing to the MR and, if required, rebase against "old" MR commits and force-push the result. (I obviously don't rebase against commits already in master).
If I need to update on a testing environment I can't do this:
git pull
...because of the force-push. So instead I do this:
git fetch --all
git checkout master
git branch -D feature_branch
git checkout feature_branch # now includes force-pushed changes
Obviously I could write my own script/hook to do this in one step. Is way to update a local branch (when I know the remote copy has been force-pushed) with fewer built-in steps?
One liner:
This updates branch
feature_branch
in the local repository by fetching from thefeature_branch
branch in the remote repository.The
+
symbol is key in that it means thefeature_branch
will be updated even if it does not fast-forward (which is typically (always?) the case with a force-pushed branch)