git-sync
Auto sync repos when pushing to git.
Install
git-sync
should be installed in your project instead of globally.
$ npm i -D @bernankez/git-sync
Usage
- Create a config file named
gitsync.config.ts
orgitsync.config.js
in the root of your project. For example
gitsync.config.ts
import { defineConfig } from "@bernankez/git-sync";
export default defineConfig({
remoteName: "origin",
url: ["git@github.com:Bernankez/git-sync.git", "git@github.com:Bernankez/example.git"]
});
- Run the CLI to update git config
$ npx git-sync
- You can also add the CLI to your
package.json
, so it can automatically run afternpm install
{
"scripts": {
"prepare": "git-sync"
}
}
Configuration
CLI
--config <path>
Specific where you want to read the config file from.
--git <path>
Specific git base dir.
Configuration file
remoteName
Remote name, defaults to origin.
fetch
If remoteName is not added, fetch will be used as the parameter when adding remote.
url
Git urls that you want to push to.
gitBaseDir
Same as --git
in CLI. --git
has higher priority than gitBaseDir
.
What's behind
git init
git remote add <config.remoteName> <config.fetch>
git remote set-url -add <config.remoteName> <config.url>
git remote -v