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 (
package.json by default, can be changed) from dependencies and devDependencies fields. This format was chosen for compatibility with javascript's package.json file format.
- 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/repo-manager file from this repo.
If you're not on mac:
- Clone this repo
- Install go
- Run
go build -o build/repo-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
repo-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
package.json with the list of your git repositories (an example of the config file is available few headers lower)
- Run the app to clone all your git repositories:
./repo-manager
Final file structure in your project:
repo-manager
package.json
.env
.env.local (optional)
.env config example
CONFIG_FILE="package.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 fields dependencies and devDependencies are used (for compatibility with standart package.json format)
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)
package.json config example
{
"devDependencies": {
"test": "git@github.com:SergeyDarn/test-module-js.git",
"storefront-query-builder": "https://github.com/DivanteLtd/storefront-query-builder.git",
},
"dependencies": {
"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
./repo-manager -h
# Run the app
./repo-manager
# Run the app without cloning repositories in parallel. Much slower, but better log readability.
./repo-manager --parallel-cloning=false
# Forcibly delete the whole directory with your git repositories before running the app.
./repo-manager --safe=false
# See the list of git repositories that have unsaved local changes. No repositories are cloned when using this flag
./repo-manager --status
# Perform git pull for all repositories
./repo-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.