Skip to content

update

Update submodule.

This will clone a missing submodule and check out the subrepository to the commit specified in the index of the containing repository. If the submodule repository doesn't contain the target commit, then the submodule is fetched using the fetch options supplied in options.

Signature

ts
class Submodule {
  update(
    init?: boolean | null | undefined,
    options?: SubmoduleUpdateOptions | null | undefined,
    signal?: AbortSignal | null | undefined,
  ): Promise<void>;
}

Parameters

  • initnull | boolean

    Indicates if the submodule should be initialized first if it has not been initialized yet.

  • optionsnull | SubmoduleUpdateOptions

    Configuration options for the update.

    • allowFetchboolean

      Allow fetching from the submodule's default remote if the target commit isn't found. Default: true.

    • checkoutCheckoutOptions

      These options are passed to the checkout step.

      • allowConflictsboolean

        In safe mode, apply safe file updates even when there are conflicts instead of canceling the checkout. Defaults to false.

      • ancestorLabelstring

        The name of the common ancestor side of conflicts

      • conflictStyleDiff3boolean

        Indicates whether to include common ancestor data in diff3 format files for conflicts. Defaults to false.

      • conflictStyleMergeboolean

        Indicate whether a normal merge file should be written for conflicts. Defaults to false.

      • dirPermnumber

        Set the mode with which new directories are created. Default is 0755

      • disableFiltersboolean

        Indicate whether to apply filters like CRLF conversion.

      • disablePathspecMatchboolean

        Treat paths specified in path as exact file paths instead of as pathspecs.

      • dryRunboolean

        Indicate that this checkout should perform a dry run by checking for conflicts but not make any actual changes.

      • filePermnumber

        Set the mode with which new files are created. The default is 0644 or 0755 as dictated by the blob.

      • forceboolean

        Take any action necessary to get the working directory to match the target including potentially discarding modified files.

      • ourLabelstring

        The name of the common our side of conflicts

      • overwriteIgnoredboolean

        Indicate whether ignored files should be overwritten during the checkout. Defaults to true.

      • pathstring

        Add a path to be checked out. The path is a <a href="https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-aiddefpathspecapathspec">pathspec</a> pattern, unless disablePathspecMatch is set. If no paths are specified, then all files are checked out. Otherwise only these specified paths are checked out.

      • recreateMissingboolean

        In safe mode, create files that don't exist. Defaults to false.

      • refreshboolean

        Indicate whether the index and git attributes should be refreshed from disk before any operations. Defaults to true,

      • removeIgnoredboolean

        Remove ignored files from the working dir. Defaults to false.

      • removeUntrackedboolean

        Remove untracked files from the working dir. Defaults to false.

      • safeboolean

        Indicate that the checkout should be performed safely, allowing new files to be created but not overwriting existing files or changes. This is the default.

      • skipUnmergedboolean

        Skip files with unmerged index entries. Defaults to false.

      • targetDirstring

        Set the directory to check out to

      • theirLabelstring

        The name of the common their side of conflicts

      • updateIndexboolean

        Prevents checkout from writing the updated files' information to the index. Defaults to true.

      • updateOnlyboolean

        Only update the contents of files that already exist. If set, files will not be created or deleted. Defaults to false.

      • useOursboolean

        Indicate whether the checkout should proceed on conflicts by using the stage 2 version of the file ("ours"). Defaults to false.

      • useTheirsboolean

        Indicate whether the checkout should proceed on conflicts by using the stage 3 version of the file ("theirs"). Defaults to false.

    • fetchFetchOptions

      Options which control the fetch, including callbacks.

      • credentialCredential

        A interface to represent git credentials in libgit2.

      • customHeadersstring[]

        Set extra headers for this fetch operation.

      • depthnumber

        Set fetch depth, a value less or equal to 0 is interpreted as pull everything (effectively the same as not declaring a limit depth).

      • downloadTagsAutotagOption

        Set how to behave regarding tags on the remote, such as auto-downloading tags for objects we're downloading or downloading all of them. The default is to auto-follow tags.

        - Unspecified : Use the setting from the remote's configuration
        - Auto : Ask the server for tags pointing to objects we're already downloading
        - None : Don't ask for any tags beyond the refspecs
        - All : Ask for all the tags

      • followRedirectsRemoteRedirect

        Set remote redirection settings; whether redirects to another host are permitted. By default, git will follow a redirect on the initial request (/info/refs), but not subsequent requests.

        - None : Do not follow any off-site redirects at any stage of the fetch or push.
        - Initial : Allow off-site redirects only upon the initial request. This is the default.
        - All : Allow redirects at any stage in the fetch or push.

      • proxyProxyOptions

        Set the proxy options to use for the fetch operation.

        • autoboolean

          Try to auto-detect the proxy from the git configuration. Note that this will override url specified before.

        • urlstring

          Specify the exact URL of the proxy to use. Note that this will override auto specified before.

      • pruneFetchPrune

        Set whether to perform a prune after the fetch.

        - Unspecified : Use the setting from the configuration.
        - On : Force pruning on.
        - Off : Force pruning off

  • signalnull | AbortSignal

    Optional AbortSignal to cancel the operation.

Released under the MIT License.