]>
Commit | Line | Data |
---|---|---|
ba2e5f1f MF |
1 | #!/bin/bash |
2 | # Helper to rewrite all local branches. | |
3 | ||
4 | rb_one() { | |
5 | local b=$1 | |
6 | ||
7 | echo "### ${b}" | |
8 | git checkout -q "${b}" || exit | |
9 | if ! git rebase ; then | |
10 | git rebase --abort | |
11 | fi | |
12 | } | |
13 | ||
14 | usage() { | |
15 | cat <<EOF | |
16 | Usage: rb-all | |
17 | EOF | |
18 | exit 1 | |
19 | } | |
20 | ||
21 | main() { | |
22 | if [[ $# -ne 0 ]] ; then | |
23 | usage | |
24 | fi | |
25 | ||
26 | local orig b branches | |
27 | orig=$(git rev-parse --abbrev-ref HEAD) || return | |
28 | ||
29 | branches=( $(git ls-remote . 'heads/*' | sed 's:.*refs/heads/::') ) | |
30 | for b in "${branches[@]}" ; do | |
31 | rb_one "${b}" | |
32 | done | |
33 | ||
34 | git checkout -q "${orig}" | |
35 | } | |
36 | main "$@" |