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

12 lines
418 B
Plaintext
Raw Normal View History

2021-09-20 06:57:20 +00:00
#!/bin/sh -e
# set repo as origin and set all branches upstream to a corresponding remote branch, if available
2021-10-14 18:25:44 +00:00
git remote $(case "$(git remote)" in
(*origin*) echo set-url;;
(*) echo add;;
esac) origin "$(git-repo "$@")"
2021-09-20 06:57:20 +00:00
git remote -v && git fetch
2021-10-14 18:25:44 +00: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