Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/holodex/git-sync
:arrow_double_down: sync a remote git url to a local dir at a branch
https://github.com/holodex/git-sync
Last synced: about 1 month ago
JSON representation
:arrow_double_down: sync a remote git url to a local dir at a branch
- Host: GitHub
- URL: https://github.com/holodex/git-sync
- Owner: holodex
- Created: 2015-07-30T04:20:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-03T11:39:10.000Z (about 9 years ago)
- Last Synced: 2024-04-27T06:51:39.799Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 118 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - holodex/git-sync - :arrow_double_down: sync a remote git url to a local dir at a branch (others)
README
# git-sync
sync a remote git url to a local dir at a branch
## install
with [npm](https://npmjs.org) installed, run
```
npm install --save git-sync
```## example
```
var gitSync = require('git-sync')var cronJob = gitSync({
remoteUrl: 'https://github.com/holodex/git-sync',
localDir: __dirname + '/dir',
branch: 'master',
cronTime: '* */15 * * * *'
}, function (err, commit) {
console.log(err, commit.id())
})
```## api
### `var cronJob = gitSync(options, cb)`
possible `options` are:
- `remoteUrl`: a url to a remote git repository
- `localDir`: a path to a local directory to store the git repository
- `branch`: an optional `String` to specify the name of a git branch
- `cronTime`: any CronTime format supported by [cron](https://www.npmjs.com/package/cron)
- `noCertificateCheck`: a boolean for whether or not to disable HTTPS certificate checking`cb` is a function that will be called every time there is an error or after the git repository is updated with a new commit. it will be called node-style, with an `Error` (if any) as the first argument and a [NodeGit `Commit`](http://www.nodegit.org/api/commit/) (if any) as the second argument.
`cronJob` returned by `gitSync()` is a [CronJob](https://www.npmjs.com/package/cron) which can be `.stop()` or `.start()`.
## faq
### https
if using an HTTPS url (`https://github.com/holodex/git-sync`) and you receive the following error:
> [Error: The SSL certificate is invalid]
then set the `noCertificateCheck` option to `true`.
### ssh
if using an SSH url (`[email protected]:holodex/git-sync`) and you receive the following error:
> [Error: authentication required but no callback set]
then post in [this issue](https://github.com/holodex/git-sync/issues/2#issuecomment-152686185) as it's not yet implemented. pull requests welcome! :)