Committing changes to a repository¶
Create a commit (snapshot of changes) within the current repository and describe those changes with a given log message. A commit will only exist within the local history until pushed back to the repository remote.
Commit a Snapshot of Repository Changes¶
Calling Commit
with a message will create a new commit within the repository:
And to verify its creation:
$ git log -n1
commit 703a6c9bc9ee91d0c226b169b131670fb92d9a0a (HEAD -> main)
Author: Purple Clay <**********(at)*******>
Date: Mon Feb 20 20:43:49 2023 +0000
feat: a brand new feature
Allowing an empty commit¶
You can create empty commits without staging any files using the WithAllowEmpty
option.
Signing a commit using GPG¶
Any commit to a repository can be GPG signed by an author to prove its authenticity through GPG verification. By setting the commit.gpgSign
and user.signingKey
git config options, GPG signing, can become an automatic process. gitz
provides options to control this process and manually overwrite existing settings per commit.
Sign an individual commit¶
If the commit.gpgSign
git config setting is not enabled; you can selectively GPG sign a commit using the WithGpgSign
option.
Select a GPG signing key¶
If multiple GPG keys exist, you can cherry-pick a key during a commit using the WithGpgSigningKey
option, overriding the user.signingKey
git config setting, if set.
Prevent a commit from being signed¶
You can disable the GPG signing of a commit by using the WithNoGpgSign
option, overriding the commit.gpgSign
git config setting, if set.
Providing git config at execution¶
You can provide git config through the WithCommitConfig
option to only take effect during the execution of a Commit
, removing the need to change config permanently.