🔄 git-sync
A tool to backup and sync your git repositories
Bug report
·
Feature request
git-sync is a CLI tool designed to help you back up your GitHub repositories. This tool ensures you have a local copy of your repositories, safeguarding against potential issues such as account bans or data loss on GitHub.
By using git-sync, you can easily clone or update your repositories to a specified local directory.
Why git-sync?
Remember when @defunkt GitHub account got banned? Well, he is the co-founder of GitHub so he did get this account un-banned but what if you are not that lucky? What if you are not the co-founder of GitHub? What if you are not even a GitHub employee.
With the increasing reliance on cloud-based repository hosting services like GitHub, it's crucial to have a backup plan. While GitHub is highly reliable, unexpected events like account bans, outages, or accidental deletions can occur.
git-sync provides a straightforward way to back up all your repositories locally, ensuring you have access to your code whenever you need it. It does this by doing a bare clone of all your repositories in a specified directory so that you can recover your code in case of any unforeseen circumstances as well as the file size of your backups is minimal.
Features
- Backup All Repositories: Automatically clone or update all your GitHub repositories to a local directory.
- Bare Clone: Efficiently back up repositories using bare clones to save space and speed up the process.
- Concurrency: Sync multiple repositories concurrently to reduce the time required for backup.
- Configuration File: Easily manage your settings through a YAML configuration file.
Installation
Prerequisites
- Go (version 1.17 or later)
- Git
Using go get
go get github.com/AkashRajpurohit/git-sync
Using git clone
git clone https://github.com/AkashRajpurohit/git-sync.git
cd git-sync
go install
Download Pre-built Binaries
Pre-built binaries are available for various platforms. You can download the latest release from the Releases page.
Usage
Configuration
Before using git-sync, you need to create a configuration file named config.yml. The default path for the configuration file is ~/.config/git-sync/config.yml.
Here's an example configuration file:
# Configuration file for git-sync
# Default path: ~/.config/git-sync/config.yml
username: your-github-username
token: your-personal-access-token
repos: []
backup_dir: /path/to/backup
include_all_repos: true
username: Your GitHub username.
token: Your GitHub personal access token. You can create a new token here. Ensure that the token has the repo scope.
repos: A list of repositories to back up. If include_all_repos is set to true, this field is ignored.
backup_dir: The directory where the repositories will be backed up. Default is ~/git-backups.
include_all_repos: If set to true, all repositories owned by the user will be backed up. If set to false, only the repositories listed in the repos field will be backed up.
Commands
Sync Repositories
To sync your repositories, run the following command:
git-sync
This command will clone or update all your repositories to the specified backup directory.
Version
To check the version of git-sync, run the following command:
git-sync version
Help
To view the help message, run the following command:
git-sync help
Bugs or Requests 🐛
If you encounter any problems feel free to open an issue. If you feel the project is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull requests are also welcome.
Where to find me? 👀
