// Public repository
./gitdump.sh <repo_name>
// Your repository (public AND private)
./gitdump.sh <your_username> user
// Organization repository (public AND private)
./gitdump.sh <your_username> orgs <your_organization_name>
Created
July 27, 2019 07:40
-
-
Save bashkirtsevich/b31ca6a3ae7a5a323b671dc4ef0572eb to your computer and use it in GitHub Desktop.
Git dumper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Args. | |
username=$1 | |
type=$2 | |
orgs=$3 | |
# Today's date | |
today="$(date +'%Y%m%d')" | |
# Call the Github API. | |
if [ "$type" = "orgs" ] | |
then | |
api=$(curl -s -u $username https://api.github.com/orgs/$orgs/repos?per_page=1000 | jq -r '.[] | .name + "|" + .clone_url + "|" + .updated_at') | |
elif [ "$type" = "user" ] | |
then | |
api=$(curl -s -u $username https://api.github.com/user/repos?per_page=1000 | jq -r '.[] | .name + "|" + .clone_url + "|" + .updated_at') | |
else | |
api=$(curl -s https://api.github.com/users/$username/repos | jq -r '.[] | .name + "|" + .clone_url + "|" + .updated_at') | |
fi | |
# Loop over the URLs and clone the repositories. | |
for i in $(echo $api | tr " " "\n") | |
do | |
name=$(echo $i | cut -d"|" -f1) | |
clone_url=$(echo $i | cut -d"|" -f2) | |
git clone $clone_url ./$name && tar -czvf ./$name.tar.gz -C ./$name . | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment