A Python script to synchronize all your personal GitHub repositories to a local directory, concurrently.
This tool automates the process of cloning and updating local copies of your GitHub repositories. It uses the GitHub GraphQL API to fetch a list of all repositories you own and then uses git to synchronize them locally.
- Python 3.10+
- Git
- GitHub Personal Access Token (PAT), with
repository metadata readingpermission
- Clone this repository.
- Create a
.envfile from the template:
cp .env.example .env- Edit
.envand add your GitHub Personal Access Token. - Setup the environment.
make setup- Run the synchronization. Activate the Python virtual environment and run the script, providing a target directory. I generally keep a local copy of my work in an external SSD. From time to time I run this script to keep local copy of my work up-to-date.
source .venv/bin/activate
python gh-sync.py /path/to/your/local/reposBy default, it synchronizes repositories one by one (concurrency = 1). You can increase this using the --concurrency (or -c) flag:
python gh-sync.py /path/to/your/local/repos --concurrency 4- Source formatting with
make format. - Cleanup Python virtual environment setup with
make clean.