1
- # ` git-context ` - Git Context Generator
1
+ # ` git-context ` - Minimalist Git Context Generator
2
2
3
3
## Overview
4
4
5
- The ` git-context ` tool generates git-related context specifically to help LLMs create meaningful commit messages.
5
+ The ` git-context ` tool generates essential git-related context to help LLMs create meaningful commit messages. This simplified version focuses on providing only the most useful information for commit message generation .
6
6
7
7
## Usage
8
8
9
9
``` bash
10
- ./git-context --diff --recent-commits=2 --prompt --conventional > commit_context.txt
10
+ ./git-context [options] > commit_context.txt
11
11
```
12
12
13
13
## Arguments
14
14
15
15
| Argument | Description | Default |
16
16
| ----------| -------------| ---------|
17
- | ` --diff ` | Show uncommitted changes | True |
18
- | ` --no-diff ` | Don't show uncommitted changes | False |
19
- | ` --staged ` | Show only staged changes | False |
20
- | ` --unstaged ` | Show only unstaged changes | False |
21
17
| ` --recent-commits=<num> ` | Show most recent N commits for context | 3 |
22
- | ` --files=<pattern> ` | Include only files matching pattern | None |
23
- | ` --exclude=<pattern> ` | Exclude files matching pattern | None |
24
- | ` --format=<format> ` | Output format (md, json, text) | "md" |
25
- | ` --prompt ` | Include commit message generation prompt | False |
26
- | ` --conventional ` | Add conventional commit format guidance | False |
27
- | ` --project-context ` | Include project name and description for context | False |
28
- | ` --branch-info ` | Include current branch and related info | False |
18
+ | ` --prompt=<file> ` | Use custom commit message prompt from file | "prompts/commit_prompt.txt" |
19
+ | ` --no-prompt ` | Don't include commit message prompt | False |
29
20
30
21
## Output
31
22
32
- The tool outputs git context information, which typically includes:
23
+ The tool outputs git context information in markdown format , which includes:
33
24
34
- 1 . Git diff of uncommitted/staged changes
35
- 2 . Information about files changed (stats)
36
- 3 . Recent commit messages for style reference
37
- 4 . Optional prompt to guide the LLM in generating a good commit message
25
+ 1 . Git status summary
26
+ 2 . Git diff of uncommitted changes against HEAD
27
+ 3 . List of files changed with their status
28
+ 4 . Recent commit messages for style reference
29
+ 5 . Commit message guidance from prompts/commit_prompt.txt
38
30
39
31
## Examples
40
32
@@ -48,48 +40,56 @@ Generate context for a commit message:
48
40
49
41
### Conventional Commits
50
42
51
- Include guidance for conventional commit format:
43
+ Use the conventional commits format guidance included in the repository :
52
44
53
45
``` bash
54
- ./git-context --prompt --conventional > commit_context.txt
46
+ ./git-context --prompt=prompts/conventional_commit.txt > commit_context.txt
55
47
```
56
48
57
- ### With Project Context
49
+ This uses the pre-defined conventional commit format guidance from the prompts directory.
58
50
59
- Include project information for better context:
51
+ ### Without Prompt
60
52
61
- ``` bash
62
- ./git-context --project-context --branch-info > commit_context.txt
63
- ```
64
-
65
- ### Staged Changes Only
66
-
67
- Only include changes that have been staged:
53
+ Generate context without the commit message guidance:
68
54
69
55
``` bash
70
- ./git-context --staged - -prompt > commit_context.txt
56
+ ./git-context --no -prompt > commit_context.txt
71
57
```
72
58
73
- ### JSON Output
59
+ ### Adjust Number of Recent Commits
74
60
75
- Generate context in JSON format :
61
+ Show more or fewer recent commits :
76
62
77
63
``` bash
78
- ./git-context --format=json > commit_context.json
64
+ ./git-context --recent-commits=5 > commit_context.txt
79
65
```
80
66
81
67
## Customization
82
68
83
69
The commit message prompt template is stored in ` prompts/commit_prompt.txt ` and can be customized to your project's needs.
84
70
85
- If the ` -- conventional` flag is used, the tool will also include guidance from ` prompts/conventional_commit.txt ` .
71
+ For conventional commits or other specialized formats, create a custom prompt file and specify it with the ` --prompt= ` option .
86
72
87
73
## Workflow Integration
88
74
89
75
Typical workflow:
90
76
91
77
1 . Make changes to your code
92
- 2 . Stage changes with ` git add `
93
- 3 . Run ` ./git-context --staged --prompt > commit_context.txt `
94
- 4 . Send commit_context.txt to an LLM to generate a commit message
95
- 5 . Use the generated message with ` git commit -m "generated message" `
78
+ 2 . Run ` ./git-context > commit_context.txt `
79
+ 3 . Send commit_context.txt to an LLM to generate a commit message
80
+ 4 . Use the generated message with ` git commit -m "generated message" `
81
+
82
+ ## Pipeline Examples
83
+
84
+ ``` bash
85
+ # Generate commit message and use it directly (using an LLM CLI tool)
86
+ git commit -am " $( ./git-context | llm -m openrouter/anthropic/claude-3.5-haiku) "
87
+
88
+ # Generate commit message but edit it before committing
89
+ git commit -am " $( ./git-context | llm -m openrouter/anthropic/claude-3.5-haiku) " -e
90
+
91
+ # Generate a conventional commit message with editing option
92
+ git commit -am " $( ./git-context --prompt=prompts/conventional_commit.txt | llm -m openrouter/anthropic/claude-3.5-haiku) " -e
93
+ ```
94
+
95
+ The ` -e ` or ` --edit ` option opens the commit message in your default editor, allowing you to review, edit, or cancel the commit if needed.
0 commit comments