может быть, это слишком поздно, но поздно ответ лучше, чем ничего:
# add the upstream:
git remote add upstream https://github.com/whoever/whatever.git
#create a script to loop through the whole branches and merge changes or create them if not found
sync_all_branch() {
git fetch upstream
for upstream_branch in $(git branch -a |awk 'BEGIN {FS="/"} $2=="upstream" {print $3}') ;
do
if git checkout $upstream_branch
then
echo merge $upstream_branch
git merge -s recursive -Xours upstream/$upstream_branch
else
echo create $upstream_branch
git checkout -b $upstream_branch upstream/$upstream_branch
fi
done
git checkout master
}
# then call the script
sync_all_branch
#push changes to your remote repository
git push --all
если вы хотите, чтобы перебазировать свои ветви на вершине восходящего потока ветвей (удалить сделанные вами изменения и не слитая в вышестоящий) , вы должны изменить
git merge -s recursive -Xours upstream/$upstream_branch
с
git rebase -s recursive -Xours upstream/$upstream_branch
и добавьте "-f", чтобы он последней команды
* сценарий sync_all_branch от https://stackoverflow.com/a/7766487/2481592
Отличный ответ. +1 – VonC