Git: Branches — различия между версиями
Материал из База знаний QPAM
(Новая страница: «* Обновить все локальные ветки по remote-веткам <syntaxhighlight lang="bash"> #!/bin/sh git for-each-ref --shell --format="%(r…») |
|||
| Строка 1: | Строка 1: | ||
| − | + | === Обновить все локальные ветки по remote-веткам === | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
#!/bin/sh | #!/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; \ | git for-each-ref --shell --format="%(refname:short)" refs/heads | tac | tr -d "'" | while read branch_name; \ | ||
do | do | ||
| Строка 8: | Строка 9: | ||
git pull | git pull | ||
done | done | ||
| − | git checkout | + | git checkout master |
| + | </syntaxhighlight> | ||
| + | |||
| + | === Rebase всех локальных веток по remote-веткам === | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | #!/bin/sh | ||
# rebase all but master: | # rebase all but master: | ||
| − | git checkout 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 | ||
| + | </syntaxhighlight> | ||
Текущая версия на 15:31, 7 марта 2024
Обновить все локальные ветки по 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