--- title: "Git" hideTitleOnPage: true --- ## GitService ### Constructors #### Constructor ```ts new GitService(transport: HttpTransport): GitService; ``` **Parameters**: - `transport` _HttpTransport_ **Returns**: - `GitService` ### Methods #### add() ```ts add(path: string, files: string[]): Promise; ``` **Parameters**: - `path` _string_ - `files` _string\[\]_ **Returns**: - `Promise` #### addRemote() ```ts addRemote(path: string, name: string, url: string): Promise; ``` **Parameters**: - `path` _string_ - `name` _string_ - `url` _string_ **Returns**: - `Promise` #### checkoutBranch() ```ts checkoutBranch(path: string, branch: string): Promise; ``` **Parameters**: - `path` _string_ - `branch` _string_ **Returns**: - `Promise` #### clone() ```ts clone(url: string, options: CloneOptions): Promise; ``` **Parameters**: - `url` _string_ - `options` _CloneOptions_ **Returns**: - `Promise` #### commit() ```ts commit( path: string, message: string, options: CommitOptions): Promise; ``` **Parameters**: - `path` _string_ - `message` _string_ - `options` _CommitOptions_ **Returns**: - `Promise` #### createBranch() ```ts createBranch(path: string, name: string): Promise; ``` **Parameters**: - `path` _string_ - `name` _string_ **Returns**: - `Promise` #### deleteBranch() ```ts deleteBranch(path: string, name: string): Promise; ``` **Parameters**: - `path` _string_ - `name` _string_ **Returns**: - `Promise` #### getConfig() ```ts getConfig(key: string, options: GitConfigOptions = {}): Promise; ``` **Parameters**: - `key` _string_ - `options` _GitConfigOptions = \{\}_ **Returns**: - `Promise` #### history() ```ts history(path: string): Promise>; ``` **Parameters**: - `path` _string_ **Returns**: - `Promise>` #### init() ```ts init(path: string, options: InitOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _InitOptions = \{\}_ **Returns**: - `Promise` #### listBranches() ```ts listBranches(path: string): Promise>; ``` List branches; response always has `{items,nextCursor}`. **Parameters**: - `path` _string_ **Returns**: - `Promise>` #### listRemotes() ```ts listRemotes(path: string): Promise>; ``` **Parameters**: - `path` _string_ **Returns**: - `Promise>` #### pull() ```ts pull(path: string, options: CredentialOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _CredentialOptions = \{\}_ **Returns**: - `Promise` #### push() ```ts push(path: string, options: PushOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _PushOptions = \{\}_ **Returns**: - `Promise` #### reset() ```ts reset(path: string, options: ResetOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _ResetOptions = \{\}_ **Returns**: - `Promise` #### restore() ```ts restore(path: string, files: string[], options: RestoreOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `files` _string\[\]_ - `options` _RestoreOptions = \{\}_ **Returns**: - `Promise` #### setConfig() ```ts setConfig(key: string, value: string, options: GitConfigOptions = {}): Promise; ``` **Parameters**: - `key` _string_ - `value` _string_ - `options` _GitConfigOptions = \{\}_ **Returns**: - `Promise` #### status() ```ts status(path: string): Promise; ``` **Parameters**: - `path` _string_ **Returns**: - `Promise` *** ## CloneOptions **Properties**: - `path` _string_ - `branch?` _string_ - `commitId?` _string_ - `depth?` _number_ - `insecureSkipTls?` _boolean_ - `username?` _string_ - `password?` _string_ - `timeout?` _number_ *** ## CommitOptions **Properties**: - `author` _string_ - `email` _string_ - `allowEmpty?` _boolean_ *** ## CredentialOptions **Properties**: - `username?` _string_ - `password?` _string_ - `branch?` _string_ - `remote?` _string_ - `timeout?` _number_ *** ## GitCommit ```ts type GitCommit = toolbox.CommitInfo ``` One commit from `git.history()`, as the daemon renders it. *** ## ListBranchResponse ```ts type ListBranchResponse = toolbox.BranchList ``` *** ## PushOptions **Properties**: - `username?` _string_ - `password?` _string_ - `branch?` _string_ - `remote?` _string_ - `timeout?` _number_ - `setUpstream?` _boolean_ *** ## ResetOptions **Properties**: - `mode?` _string_ - `target?` _string_ - `files?` _string\[\]_ *** ## RestoreOptions **Properties**: - `staged?` _boolean_ - `worktree?` _boolean_ - `source?` _string_ *** ## GitConfigScope ```ts type GitConfigScope = 'global' | 'local' ``` *** ## GitRemote **Properties**: - `name` _string_ - `url` _string_ *** ## GitStatus **Properties**: - `currentBranch` _string_ - `ahead?` _number_ - `behind?` _number_ - `branchPublished?` _boolean_ - `fileStatus?` _Array\<\{ name: string; staging?: string; worktree?: string \}\>_ *** ## GitCommitResponse ```ts type GitCommitResponse = toolbox.CommitResponse ```