add
Add a file to the git index (aka staging area)
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system implementation |
dir | string | The working tree directory path |
gitdir | string = join(dir, '.git') | The git directory path |
filepath | string | Array<string> | The path to the file to add to the index |
cache | object | a cache object |
force | boolean = false | add to index even if matches gitignore. Think git add --force |
parallel | boolean = false | process each input file in parallel. Parallel processing will result in more memory consumption but less process time |
return | Promise<void> | Resolves successfully once the git index has been updated |
Example Code:
await fs.promises.writeFile('/tutorial/README.md', `# TEST`)
await git.add({ fs, dir: '/tutorial', filepath: 'README.md' })
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')