writeRef
Write a ref which refers to the specified SHA-1 object id, or a symbolic ref which refers to the specified ref.
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
dir | string | The working tree directory path |
gitdir | string = join(dir,'.git') | The git directory path |
ref | string | The name of the ref to write |
value | string | When symbolic is false, a ref or an SHA-1 object id. When true, a ref starting with refs/ . |
force | boolean = false | Instead of throwing an error if a ref named ref already exists, overwrite the existing ref. |
symbolic | boolean = false | Whether the ref is symbolic or not. |
return | Promise<void> | Resolves successfully when filesystem operations are complete |
Example Code:
await git.writeRef({
fs,
dir: '/tutorial',
ref: 'refs/heads/another-branch',
value: 'HEAD'
})
await git.writeRef({
fs,
dir: '/tutorial',
ref: 'HEAD',
value: 'refs/heads/another-branch',
force: true,
symbolic: true
})
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')