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

13 lines
463 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
2022-03-25 08:14:30 +00:00
remote="${4:-origin}"
2021-10-14 18:25:44 +00:00
git remote $(case "$(git remote)" in
2022-03-25 08:14:30 +00:00
(*"$remote"*) echo set-url;;
2021-10-14 18:25:44 +00:00
(*) echo add;;
2022-03-25 08:14:30 +00:00
esac) "$remote" "$(git-repo "$@")"
2023-11-07 09:58:02 +00:00
git remote -v && git fetch --all
2021-10-14 18:25:44 +00:00
git branch --format='%(refname:short)' | while read branch
2023-11-07 09:58:02 +00:00
do test $(git branch --all | grep "$remote/$branch" | wc -l) -gt 0 && git branch -u "$remote/$branch" "$branch"
done