Skip to content

Instantly share code, notes, and snippets.

@ioritz1993
Forked from vke-code/download-all-repos.sh
Last active July 22, 2023 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioritz1993/be12fd85fb3fd7a502d01597e8a9bd62 to your computer and use it in GitHub Desktop.
Save ioritz1993/be12fd85fb3fd7a502d01597e8a9bd62 to your computer and use it in GitHub Desktop.
New functionality added. The added functionality allows for two different actions, depending on the state of the repository: Cloning non-existent repositories - Pulling existing repositories.
#!/bin/bash
#To run the script in the folder where we want the new repositories from a user to be downloaded, or alternatively, to be updated.
if [ $# -eq 0 ]
then
echo "Usage: $0 <user_name> "
exit;
fi
USER=$1
REPOS_LIST=$(curl -s https://api.github.com/users/$USER/repos?per_page=1000 |grep clone_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/')
for repo in $REPOS_LIST;do
repo_name=${repo%.git}
repo_name=${repo_name#https://github.com/$USER/}
if [ -d "$repo_name" ];
then
cd $repo_name;
git pull;
cd ..
else
git clone $repo;
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment