Skip to content

Instantly share code, notes, and snippets.

@ZEBAS204
Created July 7, 2021 01:30
Show Gist options
  • Save ZEBAS204/d0eff0c044e01ece0199af765fdfe912 to your computer and use it in GitHub Desktop.
Save ZEBAS204/d0eff0c044e01ece0199af765fdfe912 to your computer and use it in GitHub Desktop.
A Git Commit Messages template to follow and make life easier.
Short (max 50 chars) summary of changes (imperative)
{detailed explanatory}
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary here
Tags: {tags if using}
Resolves: {issue ID}
Fixes: {issue ID or description}
See also: {issue/PR ID}
Note: {}

Usage

Include the next line in your gitconfig or .gitconfig profile you are using:

[commit]
  template = ~/.gitCommitTemplate
  # If it is not a relative path and is in the same directory
  # template = .gitCommitTemplate

If you are using a relative path or profile, you can use this as example:

# For profiles, remove the line if you do not use different Git profiles settings (eg. D: disk)
# [includeIf "gitdir/i:D:/Projects/Codeberg/"]
    template = .gitCommitTemplate
    # or
    template: D:/git/etc/.gitCommitTemplate

Note: For Windows you need to use /i: in the path.

Global Template

If you want this template to be global in Git, use the following code in console:

$ git config --global commit.template ~/.gitCommitTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment