Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Git

Provides basic functionality for Git.

Hierarchy

  • Disposable
    • Git

Index

Methods

  • add(repository: Repository, uri: string | string[]): Promise<void>
  • Stages the given file or files in the working clone. The invocation will be rejected if any files (given with their file URIs) is not among the changed files.

    Parameters

    • repository: Repository

      the repository to stage the files.

    • uri: string | string[]

      one or multiple file URIs to stage in the working clone.

    Returns Promise<void>

  • Returns the annotations of each line in the given file.

    Parameters

    • repository: Repository

      the repository which contains the given file.

    • uri: string

      the URI of the file to get the annotations for.

    • Optional options: Blame

      more options refining the git blame.

    Returns Promise<undefined | GitFileBlame>

  • Returns with the currently active branch, or undefined if the current branch is in detached mode.

    Parameters

    • repository: Repository
    • options: { type: "current" }

      the type of the branch, which is always the current.

      • type: "current"

    Returns Promise<undefined | Branch>

  • Returns with an array of branches.

    Parameters

    • repository: Repository
    • options: { type: "local" | "remote" | "all" }

      the type of the branch, which is either the local, the remote, or all of them.

      • type: "local" | "remote" | "all"

    Returns Promise<Branch[]>

  • Creates, renames, and deletes a branch.

    Parameters

    Returns Promise<void>

  • Commits the changes of all staged files in the working directory.

    Parameters

    • repository: Repository

      the repository where the staged changes has to be committed.

    • Optional message: string

      the optional commit message.

    • Optional options: Git.Options.Commit

    Returns Promise<void>

  • Shows the difference between content pairs in the working tree, commits, or index.

    Parameters

    • repository: Repository

      the repository where where the diff has to be calculated.

    • Optional options: Diff

      optional configuration for further refining the git diff command execution.

    Returns Promise<GitFileChange[]>

  • Executes the Git command and resolves to the result. If an executed Git command exits with a code that is not in the successExitCodes or an error not in expectedErrors, a GitError will be thrown.

    Parameters

    • repository: Repository

      the repository where one can execute the command. (Although the repository path is not necessarily mandatory for each Git commands, such as git config -l, or git --version, we treat the repository as a required argument to have a symmetric API.)

    • args: string[]

      the array of arguments for Git.

    • Optional options: Execution

      options can be used to tweaked additional configurations for the low-level command execution.

    Returns Promise<GitResult>

  • Fetches branches and/or tags (collectively, refs) from the repository, along with the objects necessary to complete their histories. The remotely-tracked branches will be updated too.

    Parameters

    • repository: Repository

      the repository to fetch from.

    • Optional options: Fetch

      optional options for git fetch refinement.

    Returns Promise<void>

  • lsFiles(repository: Repository, uri: string, options: { errorUnmatch: true }): Promise<boolean>
  • lsFiles(repository: Repository, uri: string, options?: LsFiles): Promise<any>
  • Resolves to true if the file is managed by the Git repository. Otherwise, false.

    Parameters

    • repository: Repository
    • uri: string
    • options: { errorUnmatch: true }
      • errorUnmatch: true

    Returns Promise<boolean>

  • Shows information about files in the index and the working tree

    Parameters

    • repository: Repository

      the repository where the git lf-files has to be executed.

    • uri: string

      the URI of the file to check.

    • Optional options: LsFiles

      further options for the command executions.

    Returns Promise<any>

  • Fetches from and integrates with another repository. It incorporates changes from a repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

    Parameters

    • repository: Repository

      the repository to pull from.

    • Optional options: Pull

      optional refinements for the git pull command.

    Returns Promise<void>

  • Updates the refs using local refs, while sending objects necessary to complete the given refs by pushing all committed changed from the local Git repository to the remote one.

    Parameters

    • repository: Repository

      the repository to push to.

    • Optional options: Push

      optional refinements for the git push command.

    Returns Promise<void>

  • It resolves to an array of configured remotes names for the given repository.

    Parameters

    • repository: Repository

      the repository to get the remote names.

    Returns Promise<string[]>

  • It resolves to an array of configured remote objects for the given Git action.

    Parameters

    • repository: Repository

      the repository to get the remote objects.

    • options: { verbose: true }

      git remote command refinements.

      • verbose: true

    Returns Promise<Remote[]>

  • Resets the current HEAD of the entire working directory to the specified state.

    Parameters

    • repository: Repository

      the repository which state has to be reset.

    • options: Reset

      further clarifying the git reset command.

    Returns Promise<void>

  • Returns the commit SHA of the given ref if the ref exists, or returns 'undefined' if the given ref does not exist.

    Parameters

    • repository: Repository

      the repository where the ref may be found.

    • options: RevParse

      configuration containing the ref and optionally other properties for further refining the git rev-parse command execution.

    Returns Promise<undefined | string>

  • show(repository: Repository, uri: string, options?: Show): Promise<string>
  • Retrieves and shows the content of a resource from the repository at a given reference, commit, or tree. Resolves to a promise that will produce a string containing the contents of the file or an error if the file does not exists in the given revision.

    Parameters

    • repository: Repository

      the repository to get the file content from.

    • uri: string

      the URI of the file who's content has to be retrieved and shown.

    • Optional options: Show

      the options for further refining the git show.

    Returns Promise<string>

  • stash(repository: Repository, options?: Readonly<{ action?: "push"; message?: string }>): Promise<void>
  • stash(repository: Repository, options: Readonly<{ action: "list" }>): Promise<StashEntry[]>
  • stash(repository: Repository, options: Readonly<{ action: "clear" }>): Promise<void>
  • stash(repository: Repository, options: Readonly<{ action: "pop" | "apply" | "drop"; id?: string }>): Promise<void>
  • The default git stash command. Equivalent to git stash push. If the message is not defined, the Git default WIP on branchname will be used instead.

    Parameters

    • repository: Repository
    • Optional options: Readonly<{ action?: "push"; message?: string }>

    Returns Promise<void>

  • Resolves to an array of stashed entries that you currently have. Same as git stash list.

    Parameters

    • repository: Repository
    • options: Readonly<{ action: "list" }>

    Returns Promise<StashEntry[]>

  • Removes all the stash entries.

    Parameters

    • repository: Repository
    • options: Readonly<{ action: "clear" }>

    Returns Promise<void>

  • Performs stash actions depending on given action option. pop: Removes a single stashed state from the stash list and applies it on top of the current working tree state. The single stashed state is identified by the optional id. If the id is not defined the latest stash will be popped.

    apply: Like git stash pop, but does not remove the state from the stash list.

    drop: Removes a single stash entry from the list of stash entries. When the id is not given, it removes the latest one.

    Parameters

    • repository: Repository
    • options: Readonly<{ action: "pop" | "apply" | "drop"; id?: string }>

    Returns Promise<void>

  • unstage(repository: Repository, uri: string | string[], options?: Unstage): Promise<void>
  • Removes the given file or files among the staged files in the working clone. The invocation will be rejected if any files (given with their file URIs) is not among the staged files.

    Parameters

    • repository: Repository

      the repository to where the staged files have to be removed from.

    • uri: string | string[]

      one or multiple file URIs to unstage in the working clone. If the array is empty, all the changed files will be staged.

    • Optional options: Unstage

      optional refinements for the the unstaging operation.

    Returns Promise<void>