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

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 <[email protected]>' >> $HOME/.git-commit-template-authors
echo 'Mary Tester <[email protected]>' >> $HOME/.git-commit-template-authors
git-commit-template set --pair doe --dry-run

Produces:

Subject

Co-authored-by: John Doe <[email protected]>

Multiple co-authors:

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

Produces:

Subject

Co-authored-by: John Doe <[email protected]>
Co-authored-by: Mary Tester <[email protected]>

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/

About

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

Topics

Resources

License

Stars

Watchers

Forks