https://github.com/arl/prepare-commit-msg
Git prepare-commit-msg hook that prepends the commit message with the file or directory modified in the commit
https://github.com/arl/prepare-commit-msg
Last synced: 29 days ago
JSON representation
Git prepare-commit-msg hook that prepends the commit message with the file or directory modified in the commit
- Host: GitHub
- URL: https://github.com/arl/prepare-commit-msg
- Owner: arl
- License: mit
- Created: 2022-06-14T08:11:45.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-14T08:25:06.000Z (almost 4 years ago)
- Last Synced: 2025-03-23T14:42:11.121Z (about 1 year ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prepare-commit-msg
Git prepare-commit-msg hook that prepends the commit message with the file or directory modified in the commit
## Installation
```
# Build and install the binary on your system
go install github.com/arl/prepare-commit-msg@latest
# Install it as git hook
ln -s $(which prepare-commit-msg) .git/hooks/prepare-commit-msg
```
## Examples
If git status shows:
```
On branch main
Changes to be committed:
(use "git restore --staged ..." to unstage)
new file: dir1/file1
new file: dir1/file2
```
Then the git commit message will be prepared with:
```
dir1:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch main
# Changes to be committed:
# new file: dir1/file1
# new file: dir1/file2
```
If git status shows:
```
On branch main
Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: README.md
```
Then the git commit message will be prepared with:
```
README.md:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch main
# Changes to be committed:
# modified: README.md
```
If there's no common denominator between staged files, then the commit message will be prepended with `all: `