dotfiles/.local/bin/scripts/git-origin

12 lines
418 B
Text
Raw Normal View History

2021-09-20 08:57:20 +02:00
#!/bin/sh -e
# set repo as origin and set all branches upstream to a corresponding remote branch, if available
2021-10-14 20:25:44 +02:00
git remote $(case "$(git remote)" in
(*origin*) echo set-url;;
(*) echo add;;
esac) origin "$(git-repo "$@")"
2021-09-20 08:57:20 +02:00
git remote -v && git fetch
2021-10-14 20:25:44 +02:00
git branch --format='%(refname:short)' | while read branch
do test $(git branch -a | grep origin/$branch | wc -l) -gt 0 && git branch -u origin/$branch $branch
done