@bernankez/git-sync
v0.1.3
Published
Auto sync repos when pushing to git
Downloads
5
Readme
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: ["[email protected]:Bernankez/git-sync.git", "[email protected]: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 lineurl = [your incorrect git url]
in theconfig
file.
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