Skip to content

Instantly share code, notes, and snippets.

@TheLime1
Last active November 18, 2024 13:33
Show Gist options
  • Save TheLime1/bf73bed71cac051980d8b0fb9c2975f7 to your computer and use it in GitHub Desktop.
Save TheLime1/bf73bed71cac051980d8b0fb9c2975f7 to your computer and use it in GitHub Desktop.
Download a repo and all its branches
# Clone the repository
git clone https://github.com/user/repo
# Change directory to the cloned repository
cd repo
# Fetch all branches
git fetch --all
# Create a directory to store branches
mkdir ../repo-branches
# Loop through each branch and clone it into a separate folder
for branch in $(git branch -r | grep -v '\->' | grep -v 'HEAD' | sed 's/origin\///'); do
git clone --branch $branch https://github.com/user/repo ../repo-branches/$branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment