Do show the top-level working dir.
[git-shortcuts.git] / git-track-same
blob3fca999e5e3a9b3a906761282711e4d4b1606299
1 #!/bin/bash
3 usage() {
4 printf $"Usage: %s\n" "git track-same [[REMOTE]#[BRANCH]]"
5 echo $"REMOTE defaults to 'origin'; BRANCH is the one pointed to by HEAD."
6 printf $"Example: $s" \
7 'git show-ref --heads | while read sha b; do git track-same "#$b"; done'
10 case "$1" in
11 -*)
12 usage
13 exit 0
15 esac
17 set -e
19 REMOTE="${1%\#*}"
20 if ! [[ "$REMOTE" ]]; then
21 REMOTE=origin
24 case "$1" in
25 *#*) BRANCH="${1##*#}"
27 esac
28 if ! [[ "$BRANCH" ]]; then
29 BRANCH="$(git symbolic-ref HEAD)"
32 readonly BRANCHNAME="${BRANCH##refs/heads/}"
34 set -x
35 git config --add branch."$BRANCHNAME".remote "$REMOTE" \
36 && git config --add branch."$BRANCHNAME".merge "$BRANCH" \
37 && echo $"Options set."