nodegit-clone
Clone git repository with nodegit.
Install
$ npm install --save nodegit-clone
Usage
; ; // path/to/repo/.git
API
clone({ url, [localPath], [ghToken], [ssh] })
Returns a Promise, that resolves to instance of Repository.
url
Type: string
The URL to the repository.
Note: the following protocols are supported: http
, https
, git
and ssh
.
;;;;
localPath
Type: string
The Local path to store repository.
Note: if localPath
is not specified then repository will be cloned to directory with repository name.
ghToken
Type: string
The GitHub personal OAuth token.
ssh
Type: object
The object with paths to ssh keys and passphrase.
GitHub Private Repositories
Before you can clone a repository, you'll need a GitHub OAuth application token. You can find more information on generating one here: Creating an access token for command-line use.
In this example we're going to clone one of our private test repositories from GitHub. This must be an https protocol URL for the clone to work.
// Keep this value a secret. If you accidentally commit// this key to a public GitHub repository they will immediately revoke it.const GITHUB_TOKEN = '<GH_TOKEN>'; ;
SSH Keys
Before you can clone a repository, you'll need SSH keys. You can find more information on generating them here: Generating an SSH key.
In this example we're going to clone one of our private test repositories. This must be an ssh protocol URL for the clone to work.
;
For encrypted keys you should specify the passphrase
option:
;
License
MIT © Andrew Abramov