Если вам не нужно хранить историю вашей ветки, просто наведите ее на ссылку, которую вы выбрали:
git branch -f your-branch master2
Однако, чтобы сохранить историю ветки по любой причине (здесьв частности, поскольку правила сервера запрещают принудительный толчок), вы можете объединиться со стратегией ours
:
# create a copy of master2 and merge your-branch in it, BUT taking nothing from it
git checkout -b master2-copy master2
git merge -s ours your-branch
# at this point we have to reflect the operation on your-branch
# (the second merge is just a fast-forward)
git checkout your-branch
git merge master2-copy
# delete the temp branch
git branch -d master2-copy
Тогда your-branch
будет точно таким же, как master2
, но вы сможетенажмите your-branch
на пульт без усилия.