Skip to content

Command-line utility for managing a Git commit message template within the current project.

License

Notifications You must be signed in to change notification settings

carhartl/git-commit-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8b447b3 · Apr 5, 2025
Apr 5, 2025
May 31, 2023
Oct 17, 2024
Apr 5, 2025
Jun 2, 2023
Jun 2, 2023
Apr 5, 2025
Nov 29, 2024
Oct 18, 2024
May 31, 2023
Oct 17, 2024
Apr 8, 2024
Apr 8, 2024
Apr 5, 2025
Apr 5, 2025
Apr 5, 2025
Nov 29, 2024
Apr 5, 2025

Repository files navigation

git-commit-template

CI

Command-line utility for managing a Git commit message template within the current project.

  • Optional issue reference
  • Optional Co-authored-by line

Installation

With Go:

go install github.com/carhartl/git-commit-template/cmd/git-commit-template

Via Homebrew:

brew install carhartl/tap/git-commit-template

Usage

Pass issue ref numbers with or without prefix:

git-commit-template set --issue 123 --dry-run
git-commit-template set --issue #123 --dry-run

Produces:

Subject

Addresses: #123

Pass co-author with fuzzy matching entries in author file:

echo 'John Doe <john@example.com>' >> $HOME/.git-commit-template-authors
echo 'Mary Tester <mary@example.com>' >> $HOME/.git-commit-template-authors
git-commit-template set --pair doe --dry-run

Produces:

Subject

Co-authored-by: John Doe <john@example.com>

Multiple co-authors:

git-commit-template set --pair doe --pair mary --dry-run

Produces:

Subject

Co-authored-by: John Doe <john@example.com>
Co-authored-by: Mary Tester <mary@example.com>

Tip:

Due to the executable's naming you can also call it like so:

git commit-template ...

E.g. use with your favorite Git alias...

Configuration

Env var Default
GIT_COMMIT_TEMPLATE_AUTHOR_FILE $HOME/.git-commit-template-authors
GIT_COMMIT_TEMPLATE_ISSUE_PREFIX #
GIT_COMMIT_TEMPLATE_TEMPLATE Subject{{if .Issue}}\n\nAddresses: {{.Issue}}{{end}}{{if .CoAuthors}}\n{{end}}{{range .CoAuthors}}\nCo-authored-by: {{.}}{{end}}

GIT_COMMIT_TEMPLATE is a Go template string.

Releasing

op run --env-file .env -- ./release.sh 0.1.0

Also see

https://cbea.ms/git-commit/