Skip to content

johnkattenhorn/git-repo-cloner

Repository files navigation

Repository Cloning Scripts

A collection of PowerShell scripts for automatically cloning repositories from Azure DevOps and GitHub organizations.

Overview

These scripts help developers maintain local copies of all repositories they have access to across different Git hosting platforms. They automatically discover, clone, and keep repositories up to date with a clean, organized directory structure.

Scripts Included

1. Azure DevOps Repository Cloner (clone.ps1)

  • Purpose: Clones all repositories from all projects in an Azure DevOps organization
  • Authentication: Uses Azure CLI (no manual token management)
  • Features: Multi-project support, automatic organization, smart updates
  • Documentation: README-AzureDevOps-Clone.md

2. GitHub Repository Cloner (clone-github.ps1)

  • Purpose: Clones all GitHub repositories you have access to (personal, organization, collaborator)
  • Authentication: Uses GitHub Personal Access Token
  • Features: Multi-source support, private repo handling, organization discovery
  • Documentation: README-GitHub-Clone.md

Quick Start

For Azure DevOps:

  1. Install and authenticate Azure CLI: az login
  2. Configure CloneAllRepos.config
  3. Run: powershell -ExecutionPolicy Bypass -File clone.ps1

For GitHub:

  1. Create a GitHub Personal Access Token
  2. Configure CloneGitHubRepos.config
  3. Run: powershell -ExecutionPolicy Bypass -File clone-github.ps1

Directory Structure

After running both scripts, you'll have:

C:\Git\
├── YourOrganization\          # Azure DevOps repos
│   ├── Project1\
│   │   ├── Repo1\
│   │   └── Repo2\
│   └── Project2\
│       └── Repo3\
└── GitHub\                    # GitHub repos
    └── YourUsername\
        ├── PersonalRepo1\
        ├── PersonalRepo2\
        └── OrganizationRepo1\

Prerequisites

  • PowerShell: Windows PowerShell or PowerShell Core
  • Git: Must be installed and configured
  • Azure CLI: For Azure DevOps script (install via winget install Microsoft.AzureCLI)
  • GitHub Personal Access Token: For GitHub script

Configuration Files

Azure DevOps (CloneAllRepos.config)

[General]
Url=https://dev.azure.com/YourOrganization/project

[LocalGitConfig]
GitPath=C:\Git\
OrgName=YourOrganization

[GitOptions]
PruneLocalBranches=false
GitEmail[email protected]

GitHub (CloneGitHubRepos.config)

[GitHub]
GitHubUsername=your-github-username
GitHubToken=your-github-personal-access-token

[LocalGitConfig]
GitPath=C:\Git\

[GitOptions]
PruneLocalBranches=false
GitEmail[email protected]

Features Comparison

Feature Azure DevOps GitHub
Multi-project/org support
Private repository support
Automatic directory organization
Smart updates (clone/pull)
Branch pruning
Pagination support
Error handling
Progress tracking
Authentication method Azure CLI Personal Access Token

Use Cases

  • Development Teams: Keep all organization repositories locally available
  • Consultants: Maintain access to multiple client repositories
  • Open Source Contributors: Track repositories across different organizations
  • Backup Strategy: Local copies of all accessible repositories
  • Offline Development: Work with repositories when internet is limited

Security Considerations

Azure DevOps

  • Uses Azure CLI authentication (secure, no stored tokens)
  • Repository URLs logged to console
  • No credentials stored in plain text

GitHub

  • Personal Access Token stored in config file
  • Token should have minimal required scopes
  • Consider token expiration and rotation
  • Repository URLs logged to console

Troubleshooting

Common Issues

  1. Authentication errors: Check Azure CLI login or GitHub token
  2. Permission denied: Verify access to organizations/projects
  3. Directory creation failed: Check file system permissions
  4. Rate limiting: Wait and retry (GitHub)

Getting Help

  • Check the individual script documentation for detailed troubleshooting
  • Verify prerequisites are met
  • Ensure configuration files are properly formatted
  • Check network connectivity and firewall settings

Contributing

Feel free to enhance these scripts with:

  • Additional Git providers (GitLab, Bitbucket, etc.)
  • Repository filtering options
  • Parallel cloning for performance
  • Custom branch management
  • Integration with CI/CD systems

License

These scripts are provided as-is for educational and development purposes.

Support

For issues or questions:

  1. Check the individual script documentation
  2. Verify your configuration
  3. Test with a small subset of repositories first
  4. Review the troubleshooting sections

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published