]> git.phdru.name Git - git-scripts.git/blob - update-remotes
Feat(update-remotes): Force-push branches to `web`
[git-scripts.git] / update-remotes
1 #! /bin/sh
2
3 current="`git config --get --path remote.current.url`"
4 origin="`git config --get --path remote.origin.url`"
5 branches="master ${1:+$@}"
6
7 if [ -n "$origin" ]; then
8    if [ -n "$current" ]; then
9       echo "Config error (both origin and current)" >&2
10       exit 1
11    else
12       cd "$origin" &&
13       exec ./update-remotes
14    fi
15 elif [ -z "$current" ]; then
16    echo "Wrong directory error (neither origin nor current)" >&2
17    exit 1
18 fi
19
20 git fetch current &&
21 { git pull --ff-only current master || git reset --hard current/master ; } &&
22
23 web="`git config --get --path remote.web.url`" &&
24 if [ -n "$web" ]; then
25    git push --force web $branches
26 fi &&
27
28 cd "$current" && exec git pull origin