Auto sync repos when pushing to git.
git-sync
should be installed in your project instead of globally.
$ npm i -D @bernankez/git-sync
- 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"
}
}
Note
If you accidentally set the wrong git url and it has been added to your git, please go to the [project root dir]/.git
and remove the line url = [your incorrect git url]
in the config
file.
Specific where you want to read the config file from.
Specific git base dir.
Remote name, defaults to origin.
If remoteName is not added, fetch will be used as the parameter when adding remote.
Git urls that you want to push to.
Same as --git
in CLI. --git
has higher priority than gitBaseDir
.
git init
git remote add <config.remoteName> <config.fetch>
git remote set-url --add <config.remoteName> <config.url>
git remote -v