Interface WorkingTreeFile

Options for checking out files from the working tree.

  • When trying to revert a resource to the state of the index, set paths.
  • When trying to revert the state of a resource to the repository HEAD, then set paths and treeish to HEAD.
  • If you would like to check out the state of a file from the HEAD of a branch, set treeish to nameOfTheBranch.
  • And if you would like to check out a historical revision of a branch, set treeish to nameOfTheBranch~2 which will be two commits before the most recent one on the desired branch.
interface WorkingTreeFile {
    force?: boolean;
    merge?: boolean;
    paths: string | string[];
    treeish?: string;
}

Properties

force?: boolean

When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored.

merge?: boolean

When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths.

paths: string | string[]

This is used to restore modified or deleted paths to their original contents from the index or replace paths with the contents from a named tree-ish (most often a commit-ish).

One can specify a regular expression for the paths, in such cases, it must be escaped with single-quotes. For instance checking out a Hello.ts file will be simply "Hello.ts", if one would like to checkout all TS files, then this for should be used: ts const options = { paths: `'*.ts'` } .

treeish?: string

Tree to checkout from. If not specified, the index will be used. git checkout -- ./fileName.ext. If you want to get the state from the repository ,use HEAD which will be equivalent with git checkout HEAD -- ./fileName.ext.