clone
Clone a repository
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system implementation |
http | HttpClient | an HTTP client |
onProgress | ProgressCallback | optional progress event callback |
onMessage | MessageCallback | optional message event callback |
onAuth | AuthCallback | optional auth fill callback |
onAuthFailure | AuthFailureCallback | optional auth rejected callback |
onAuthSuccess | AuthSuccessCallback | optional auth approved callback |
onPostCheckout | PostCheckoutCallback | optional post-checkout hook callback |
dir | string | The working tree directory path |
gitdir | string = join(dir,'.git') | The git directory path |
url | string | The URL of the remote repository |
corsProxy | string | Optional CORS proxy. Value is stored in the git config file for that repo. |
ref | string | Which branch to checkout. By default this is the designated "main branch" of the repository. |
singleBranch | boolean = false | Instead of the default behavior of fetching all the branches, only fetch a single branch. |
noCheckout | boolean = false | If true, clone will only fetch the repo, not check out a branch. Skipping checkout can save a lot of time normally spent writing files to disk. |
noTags | boolean = false | By default clone will fetch all tags. noTags disables that behavior. |
remote | string = 'origin' | What to name the remote that is created. |
depth | number | Integer. Determines how much of the git repository's history to retrieve |
since | Date | Only fetch commits created after the given date. Mutually exclusive with depth . |
exclude | Array<string> = [] | A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs. |
relative | boolean = false | Changes the meaning of depth to be measured from the current shallow depth rather than from the branch tip. |
headers | Object<string, string> = {} | Additional headers to include in HTTP requests, similar to git's extraHeader config |
cache | object | a cache object |
return | Promise<void> | Resolves successfully when clone completes |
Example Code:
await git.clone({
fs,
http,
dir: '/tutorial',
corsProxy: 'https://cors.isomorphic-git.org',
url: 'https://github.com/isomorphic-git/isomorphic-git',
singleBranch: true,
depth: 1
})
console.log('done')
Tip: If you need a clean slate, expand and run this snippet to clean up the file system.
window.fs = new LightningFS('fs', { wipe: true })
window.pfs = window.fs.promises
console.log('done')