{"id":18947645,"url":"https://github.com/yousafkhamza/github_cloner_bash_script","last_synced_at":"2026-05-07T18:33:09.254Z","repository":{"id":195965540,"uuid":"450894502","full_name":"yousafkhamza/GitHub_Cloner_Bash_Script","owner":"yousafkhamza","description":"This is a simple bash script for cloning all the repositories under a GitHub user. if you're using a GitHub personal access token with repo privilege then you can clone the private repos too. Also, please note that the bash script is working with GitHub API and forked repos can't be able to clone.","archived":false,"fork":false,"pushed_at":"2022-01-23T04:10:05.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-01T01:19:58.255Z","etag":null,"topics":["bash-script","github","githubapi","githubclone"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yousafkhamza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-01-22T17:56:47.000Z","updated_at":"2022-01-23T04:10:47.000Z","dependencies_parsed_at":"2023-09-20T20:13:37.679Z","dependency_job_id":null,"html_url":"https://github.com/yousafkhamza/GitHub_Cloner_Bash_Script","commit_stats":null,"previous_names":["yousafkhamza/github_cloner_bash_script"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2FGitHub_Cloner_Bash_Script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2FGitHub_Cloner_Bash_Script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2FGitHub_Cloner_Bash_Script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2FGitHub_Cloner_Bash_Script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yousafkhamza","download_url":"https://codeload.github.com/yousafkhamza/GitHub_Cloner_Bash_Script/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239946876,"owners_count":19723014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","github","githubapi","githubclone"],"created_at":"2024-11-08T13:10:49.227Z","updated_at":"2026-05-07T18:33:09.211Z","avatar_url":"https://github.com/yousafkhamza.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Cloner Bash Script\n[![Build](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\n---\n## Description\nThis is a simple bash script for cloning all the repositories under a GitHub user. if you're using a GitHub personal access token with repo privilege then you can clone the private repos too. Also, please note that the bash script is working with GitHub API and forked repos can't be able to clone. So, I will be adding the same on future releases. \n\n----\n## Feature\n- Easy to clone all the repos under a GitHub User.\n- Working with GitHub API.\n- Private repos can clone with personal GitHub Token.\n\n----\n## Pre-Requests\n- GitHub Token (if you need your personal/repos not mandatory)\n\n#### GitHub Token Generator\n\u003e Private Repos Cloning you guys need a personal GitHub Token from your repo so please be follow the below article and create the same from your end. (Please make sure we need repo privilege)\n\n[Click here for Token Article](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\n\n\n#### Pre-Requests (for RedHat-based-Linux)\n```\nyum install -y git\n```\n\n#### Pre-Requests (for Debian-based-Linux)\n````\napt install -y git\n````\n\n#### Pre-Requests (for Termux-based-Linux)\n````\npkg upgrade\npkg install git\n````\n\n----\n## Modules Used\n- [GitHub API](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\n\n---\n## How to Get\n```\ngit clone https://github.com/yousafkhamza/GitHub_Cloner_Bash_Script.git\ncd GitHub_Cloner_Bash_Script\nchmod +x cloner.sh\n```\n\n----\n## How to execute\n```\n/bin/bash cloner.sh \u003cUSERNAME\u003e \u003cIf you have a token please enter your GITHUB TOKEN HERE\u003e\n```\n\n----\n## Output be like\n`Cloning without GitHub API token so please see the below screenshots with and without token`\n```\nyousaf@MSI:/mnt/c/Users/yousa/GitHub_Cloner_Bash_Script$ /bin/bash cloner.sh newakhilguru\n        ____ ___ _____ _   _ _   _ ____     ____ _     ___  _   _ _____ ____\n       / ___|_ _|_   _| | | | | | | __ )   / ___| |   / _ \\| \\ | | ____|  _ \\\n      | |  _ | |  | | | |_| | | | |  _ \\  | |   | |  | | | |  \\| |  _| | |_) |\n      | |_| || |  | | |  _  | |_| | |_) | | |___| |__| |_| | |\\  | |___|  _ \u003c\n       \\____|___| |_| |_| |_|\\___/|____/   \\____|_____\\___/|_| \\_|_____|_| \\_\\\n\n         GitHub Cloner v1 Author: @yousafkhamza (Github|Instagram|LinkedIn)\n\n\n..................Welcome to the Script..................\nLet's start to clone repos from GitHub, also, please note that the script won't download forked repos....\n\nPlease specify a GitHub Token Otherwise can't able to clone your private repos.\nDo you want to continue without private repos [Y/N]: y\nFetched Repo list below (without forked):\n---------\ngit@github.com:newakhilguru/newakhilguru.git\ngit@github.com:newakhilguru/mssqlbackup.bat.git\n---------\nCloning starts in 10sec...\nif you wouldn't like to clone the repos please be exit the script meanwhile the countdown using [ctrl + c]....\nCountdown Begins...\n9..\n8..\n7..\n6..\n5..\n4..\n3..\n2..\n1..\n0..\nCloning Starts...\n-----\nCloning into 'newakhilguru'...\nwarning: You appear to have cloned an empty repository.\n-----\nCloning into 'mssqlbackup.bat'...\nremote: Enumerating objects: 3, done.\nremote: Counting objects: 100% (3/3), done.\nremote: Compressing objects: 100% (2/2), done.\nremote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0\nUnpacking objects: 100% (3/3), 678 bytes | 2.00 KiB/s, done.\n-----\nCloning Completed\nPlease take a look under /mnt/c/Users/yousa/GitHub_Cloner_Bash_Script/Clonings/Clonings/ Directory\n```\n### _Screenshots_\n\n`Without GitHub API Token`\n![alt_txt](https://i.ibb.co/25vGxjQ/Screenshot-2.png)\n![alt_txt](https://i.ibb.co/MpMjFBH/Screenshot-3.png)\n\n`With GitHub API Token`\n![alt_txt](https://i.ibb.co/0KJk7Fr/Screenshot-4.png)\n![alt_txt](https://i.ibb.co/mvkxzmD/Screenshot-5.png)\n\n----\n## Behind the code\n````\n#!/bin/bash\n# Author: Yousaf K Hamza\n# Description: GitHub Repository Cloning bash Script\n\nprintf \"\\e[1;92m        ____ ___ _____ _   _ _   _ ____     ____ _     ___  _   _ _____ ____      \\e[0m\\n\"\nprintf \"\\e[1;92m       / ___|_ _|_   _| | | | | | | __ )   / ___| |   / _ \\| \\ | | ____|  _ \\     \\e[0m\\n\"\nprintf \"\\e[1;92m      | |  _ | |  | | | |_| | | | |  _ \\  | |   | |  | | | |  \\| |  _| | |_) |    \\e[0m\\n\"\nprintf \"\\e[1;92m      | |_| || |  | | |  _  | |_| | |_) | | |___| |__| |_| | |\\  | |___|  _ \u003c     \\e[0m\\n\"\nprintf \"\\e[1;92m       \\____|___| |_| |_| |_|\\___/|____/   \\____|_____\\___/|_| \\_|_____|_| \\_\\    \\e[0m\\n\"\n\nprintf \"\\n\"\nprintf \"\\e[1;77m\\e[45m         GitHub Cloner v1 Author: @yousafkhamza (Github|Instagram|LinkedIn)          \\e[0m\\n\"\nprintf \"\\n\"\n\necho \"\"\necho \"..................Welcome to the Script..................\"\necho \"Let's start to clone repos from GitHub, also, please note that the script won't download forked repos....\"\necho \"\"\n\nGit_User=$1\nGit_Token=$2\nrm -f .git_repo_list.txt\n\nfunction cloner_main {\n    echo \"Fetched Repo list below (without forked): \"\n    echo \"---------\"\n    cat .git_repo_list.txt\n    echo \"---------\"\n    repo_count=$(cat .git_repo_list.txt | wc -l)\n    if [ $repo_count == 0 ];then\n        echo \"Can't able to Fetch user repos.\"\n        exit 1\n    fi \n    echo \"Cloning starts in 10sec...\" \n    echo \"if you wouldn't like to clone the repos please be exit the script meanwhile the countdown using [ctrl + c]....\"\n    echo \"Countdown Begins...\"\n    count=9; ((++count)) ; while ((--count \u003e=0)); do sleep 1; echo -e \"\\033[31;5m$count..\\033[0m\"; done; #backword countdown\n    echo \"Cloning Starts...\"\n    if [ ! -d \"./Clonings\" ]; then\n        mkdir ./Clonings\n    else\n        rm -f ./Clonings/.git_repo_list.txt\n    fi\n    cp .git_repo_list.txt ./Clonings/.git_repo_list.txt\n    cd ./Clonings\n    for item in $(cat .git_repo_list.txt | cut -d: -f2); do echo \"-----\" \u0026\u0026 git clone https://github.com/$item; done\n    echo \"-----\" \n    echo \"Cloning Completed\"\n    echo \"Please take a look under $(pwd)/Clonings/ Directory\"\n    exit 1\n}\n\nif [ -z \"$Git_User\" ]\nthen\n    echo \"Please specify a GitHub UserName.\"\n    exit 1\nfi\n\n# without token\nif [ -z \"$Git_Token\" ]\nthen\n    echo \"Please specify a GitHub Token Otherwise can't able to clone your private repos.\"\n    read -p 'Do you want to continue without private repos [Y/N]: ' ask1\n    if [[ \"$ask1\" =~ ^([yY][eE][sS]|[yY])+$ ]];then\n        curl -s \"https://api.github.com/search/repositories?q=user:$Git_User\u0026per_page=200\" | grep -o 'git@[^\"]*' \u003e .git_repo_list.txt\n        cloner_main\n    else\n        echo \"Quited. Thank you for using the script.\"\n        exit 1\n    fi\nfi\n\n#if you have token\ncurl -s -H \"Authorization: token $Git_Token\" \"https://api.github.com/search/repositories?q=user:$Git_User\u0026per_page=200\" | grep -o 'git@[^\"]*' \u003e .git_repo_list.txt\necho \"You are entering the token so will clone the private repos too.\"\ncloner_main\n\n###################################################Thank_You#######################################################\n````\n\n----\n## Conclusion\nThis is a simple bash script for cloning all the private \u0026 public repos except forked repos under a GitHub user. I hope this would be helpful to anyone so please let me know if you have any comments.\n\n### ⚙️ Connect with Me \n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"mailto:yousaf.k.hamza@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Gmail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://www.instagram.com/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge\u0026logo=instagram\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://wa.me/%2B917736720639?text=This%20message%20from%20GitHub.\"\u003e\u003cimg src=\"https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white\"/\u003e\u003c/a\u003e\u003cbr /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fgithub_cloner_bash_script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyousafkhamza%2Fgithub_cloner_bash_script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fgithub_cloner_bash_script/lists"}