summaryrefslogtreecommitdiffstats
path: root/mirrorit
blob: 9f2298d2b708d09d5fbbfe4e59cb6664b0a5c2a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env bash

repository_url="$1"
repository_destination="$2"

fail() {
    echo >&2 "$*"
    exit 1
}

if [ -d "$repository_destination" ]; then
    cd "$repository_destination" || fail "could not cd to $repository_destination"

    git fetch
else
    git clone --mirror "$repository_url" "$repository_destination"
fi