Created
January 13, 2026 21:13
-
-
Save Neolot/7ad46f4160a86c0abdf1b6cafcc26a28 to your computer and use it in GitHub Desktop.
Bulk clone git-repositories from the file
This file contains hidden or 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
| #!/bin/bash | |
| # Filename containing the list of repositories | |
| FILE="repos.txt" | |
| # 1. Check if repos.txt exists | |
| if [ ! -f "$FILE" ]; then | |
| echo "Error: File $FILE not found in the current directory." | |
| exit 1 | |
| fi | |
| echo "Starting cloning of repositories from $FILE..." | |
| echo "-----------------------------------" | |
| # 2. Read file line by line | |
| # The "|| [ -n ... ]" part ensures the last line is read even if it doesn't end with a newline | |
| while IFS= read -r repo_url || [ -n "$repo_url" ]; do | |
| # Remove leading/trailing whitespace (trim) | |
| repo_url=$(echo "$repo_url" | xargs) | |
| # Skip empty lines | |
| if [ -z "$repo_url" ]; then | |
| continue | |
| fi | |
| # Skip lines starting with # (comments) | |
| if [[ "$repo_url" == \#* ]]; then | |
| continue | |
| fi | |
| echo "Cloning: $repo_url" | |
| # 3. Execute git clone | |
| git clone "$repo_url" | |
| # Check execution status | |
| if [ $? -eq 0 ]; then | |
| echo "✅ Success: $repo_url" | |
| else | |
| echo "❌ Error cloning: $repo_url" | |
| fi | |
| echo "-----------------------------------" | |
| done < "$FILE" | |
| echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment