Save-GitChange

Commits changes to a Git repository.

Syntax

Save-GitChange [-Message] <String> [[-RepoRoot] <String>] [<CommonParameters>]

Description

The Save-GitChange function commits changes to a Git repository. Those changes must be staged first with git add or the LibGit2 module's Add-GitItem function. If there are no changes staged, nothing happens and you'll see a warning.

You are required to pass a commit message with the Message parameter. This module is intended to be used by non-interactive repository automation scripts, so opening in an editor is not supported.

Implements the git commit command.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Message String

The commit message.

true false
RepoRoot String

The repository where to commit staged changes. Defaults to the current directory.

false false

Return Values

LibGit2.Automation.CommitInfo.

EXAMPLE 1

Save-GitChange -Message 'Creating Save-GitChange function.'

Demonstrates how to commit staged changes in a Git repository. In this example, the repository is assumed to be in the current directory.

EXAMPLE 2

Save-GitChange -Message 'Creating Save-GitChange function.' -RepoRoot 'C:\Projects\LibGit2.PowerShell'

Demonstrates how to commit changes to a repository other than the current directory.