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

10 lines
381 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
git remote remove origin 2>/dev/null
git remote add origin $(git-repo "$@")
2021-09-20 06:57:20 +00:00
git remote -v && git fetch
git branch | sed 's/ //g' | sed 's/*//' | while read branch
do test $(git branch -a | grep origin/$branch | wc -l) -gt 0 && git branch -u origin/$branch $branch
done