Git repositories manager
Readable slow install (parallel cloning off)
Fast install (default, parallel install on)
Git status for all repositories
Git pull in all repositories
How it works
- The list of git repositories to clone is read from the config file (
repos-manager-config.json by default, can be changed) from the repositories field.
- All git repositories are cloned into the specified folder (
src/repos by default, can be changed)
- Before cloning a repo, the local folder with this repo is deleted if it exists.
- If a repository has unsaved changes, it is skipped so you won't lose any changes
How to use
If you're on mac, you can just use already compiled build/repos-manager file from this repo.
If you're not on mac:
- Clone this repo
- Install go
- Run
go build -o build/repos-manger inside the cloned repo to generate a compiled file for your operating system (instead of repo-manager you can use any filename)
- Copy the
repos-manager file that contains the app from build directory to the place where you want to manage multiple git repositories.
- Copy
.env file from this repository to the same place. It contains the environment variables required for the app to run.
- You can change any environment variables you want in
.env + the app also reads a file .env.local
!Important! If you're cloning git repositories with ssh - set the path to your ssh key in the env config file.
- Create
repos-manager-config.json with the list of your git repositories (an example of the config file is available few headers below)
- Run the app to clone all your git repositories:
./repos-manager
Final file structure in your project:
repos-manager
repos-manager-config.json
.env
.env.local (optional)
.env config example
CONFIG_FILE="repos-manager-config.json"
REPOS_DIR="src/repos"
SSH_KEY_PATH="/Users/your_username/.ssh/id_rsa"
SSH_KEY_PASSWORD=""
CONFIG_FILE - the name of the JSON file from which the list of git repositories to clone is read. Inside, the field repositories is used
REPOS_DIR - relative path to the directory to which git repositories will be cloned. Don't forget to add it to .gitignore
SSH_KEY_PATH - absolute(!) path to your local private ssh key
SSH_KEY_PASSWORD - your ssh key password (if there's none - leave empty)
repos-manager-config.json config example
{
"repositories": {
"test": "git@github.com:SergeyDarn/test-module-js.git",
"storefront-query-builder": "https://github.com/DivanteLtd/storefront-query-builder.git",
"scrape-search-ai": "https://github.com/SergeyDarn/scrape-search-ai#dev",
"magnific-popup": "git@github.com:SergeyDarn/Magnific-Popup.git#1.8.0",
"Course_Bash": "git@github.com:SergeyDarn/Course_Bash-Programming.git#3a7a19020151b45a29896c9142723efe5b11a061"
}
}
- Repository
test-module-js with the name test. Normal ssh link
- Repository
storefront-query-builder. Normal https link
- Repository
scrape-search-ai. Https link with the branch dev
- Repository
Magnific-Popup with the name magnific-popup. Ssh link with the tag 1.8.0 (the app uses \d(\..*)+ regex for determining that it's a tag).
- Repository
Course_Bash-Programming with the name Course_Bash. Ssh link with a specific commit hash
Available commands
# Help. List all available commands
./repos-manager -h
# Run the app
./repos-manager
# Run the app without cloning repositories in parallel. Much slower, but better log readability.
./repos-manager --parallel-cloning=false
# Forcibly delete the whole directory with your git repositories before running the app.
./repos-manager --safe=false
# See the list of git repositories that have unsaved local changes. No repositories are cloned when using this flag
./repos-manager --status
# Perform git pull for all repositories
./repos-manager --pull
Usage as a go module
This app can also be installed as a go module in your go program. It wasn't planned at first, but I decided to implement it for my Configs Manager app. It's not pretty and for sure doesn't follow the best practices for creating go modules (because I don't know them), but it works.