summaryrefslogtreecommitdiff
path: root/clone-all-github
blob: 02699549c3a5b65a453f87c853c2e2d5b3931131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

USER=compromyse
REPOS=$(curl https://api.github.com/users/$USER/repos 2>/dev/null | jq -r '.[].name')

for rawname in $REPOS; do
    repo=$rawname.git

    if [ ! -d $HOME/$repo ]; then

        git clone --bare https://github.com/$USER/$repo $HOME/$repo

        pushd $HOME/$repo > /dev/null

            for remote in $(git remote show); do
                git remote remove $remote
                git remote add github git@github.com:$USER/$repo
                git fetch github
            done

        popd > /dev/null

    fi
done