Skip to content

commit

Create new commit in the repository.

If the updateRef is not null, name of the reference that will be updated to point to this commit. If the reference is not direct, it will be resolved to a direct reference. Use "HEAD" to update the HEAD of the current branch and make it point to this commit. If the reference doesn't exist yet, it will be created. If it does exist, the first parent must be the tip of this branch.

Signature

ts
class Repository {
  commit(tree: Tree, message: string, options?: CommitOptions | null): string;
}

Parameters

  • treerequired · Tree
  • messagerequired · string
  • optionsnull | CommitOptions
    • authorSignaturePayload

      Signature for author. If not provided, the default signature of the repository will be used. If there is no default signature set for the repository, an error will occur.

      • emailrequired · string

        Email on the signature.

      • namerequired · string

        Name on the signature.

      • timeOptionsSignatureTimeOptions
        • offsetnumber

          Timezone offset, in minutes

        • timestamprequired · number

          Time in seconds, from epoch

    • committerSignaturePayload

      Signature for commiter. If not provided, the default signature of the repository will be used. If there is no default signature set for the repository, an error will occur.

      • emailrequired · string

        Email on the signature.

      • namerequired · string

        Name on the signature.

      • timeOptionsSignatureTimeOptions
        • offsetnumber

          Timezone offset, in minutes

        • timestamprequired · number

          Time in seconds, from epoch

    • parentsstring[]
    • updateRefstring

Returns

  • string

    ID(SHA1) of created commit.

Released under the MIT License.