Git: Branches

Материал из База знаний QPAM
Перейти к: навигация, поиск

Обновить все локальные ветки по remote-веткам[править]

#!/bin/sh
#update all local branches by remotes
git for-each-ref --shell --format="%(refname:short)" refs/heads | tac | tr -d "'" | while read branch_name; \
do
    echo ${branch_name}
    git checkout ${branch_name}
    git pull
done
git checkout master‎


Rebase всех локальных веток по remote-веткам[править]

#!/bin/sh
# rebase all but master:
git checkout master
git fetch origin --prune
git merge
for branch_name in $(git for-each-ref --shell --format='%(refname:short)' refs/heads | head -n -1 | tac | xargs); do
    git checkout ${branch_name}
    git rebase master
    git push origin -f
done
git checkout master‎