Git Operations
Handle git operations using
Conventional Commits v1.0.0.
Commit Message Format
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types
| Type |
Description |
SemVer |
feat |
New feature |
MINOR |
fix |
Bug fix |
PATCH |
docs |
Documentation only |
- |
style |
Formatting, no code change |
- |
refactor |
Neither fix nor feature |
- |
perf |
Performance improvement |
PATCH |
test |
Adding/correcting tests |
- |
build |
Build system, dependencies |
- |
ci |
CI configuration |
- |
chore |
Other non-src/test changes |
- |
revert |
Reverts a previous commit |
- |
Rules
- Description: imperative mood, lowercase, no period, ≤50 chars (72 for body)
- Scope: noun in parentheses describing affected area, e.g.,
feat(api):, fix(parser):, docs(readme):
- Body: explain what and why, not how (blank line after description)
- Footer: use for breaking changes, issue refs, co-authors
- Breaking changes: append exclamation mark after type/scope OR add
BREAKING CHANGE: footer (triggers MAJOR)
- Example:
feat!: or refactor(api)!:
- Use double quotes in shell commands, not single quotes
Examples
feat: add user authentication
fix: resolve memory leak in data processor
docs: correct spelling of CHANGELOG
feat(lang): add Polish language
fix: prevent racing of requests
Introduce a request id and a reference to latest request.
Dismiss incoming responses other than from latest request.
Refs: #123
feat!: drop support for Node 14
BREAKING CHANGE: Node 14 has reached end-of-life. Minimum required version is now Node 18.
refactor(api)!: rename endpoints for consistency
/users → /api/users
/posts → /api/posts
BREAKING CHANGE: All REST endpoints now prefixed with /api
revert: revert "feat: add experimental caching layer"
This reverts commit 676104e.
The caching implementation caused data inconsistencies in production.
Refs: #456
Commit Workflow
git status — review all changes
git diff [--staged] — understand what changed
- Analyze grouping — split if changes are logically independent:
- Different types (
feat + fix → 2 commits)
- Unrelated areas (frontend + backend for different features → 2 commits)
- Keep related changes together (one feature across multiple files → 1
commit)
- For each logical group:
- Stage specific files:
git add <files> (never blind git add .)
- Commit:
- Simple:
git commit -m "type(scope): description"
- With body:
git commit -m "type: description" -m "Body paragraph"
- With editor:
git commit (for complex messages with body/footer)
git status — verify completion
Rules
Pre-commit Checks
Before committing, verify:
- Secrets: Exclude
.env, credentials.json, API keys, tokens
- Tests: Run
npm test, pytest, cargo test, or project-specific commands
- Linting: Run linters/formatters (
eslint, prettier, ruff, etc.)
- Hooks: Check if pre-commit hooks exist (
.git/hooks/pre-commit)
- Unintended files: Review
git status output carefully
Amending
git commit --amend # edit message and content
git commit --amend --no-edit # keep message, add staged changes
⚠️ Warn user if commit was already pushed (requires --force).
Push
git push # existing upstream
git push -u origin <branch> # new branch
1---2name: git-use3description: Git operations with conventional commits.4---5
6# Git Operations
7
8Handle git operations using
9[Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/).
10
11## Commit Message Format
12
13```
14<type>[optional scope]: <description>
15
16[optional body]
17
18[optional footer(s)]
19```
20
21### Types
22
23| Type | Description | SemVer |
24| ---------- | -------------------------- | ------ |
25| `feat` | New feature | MINOR |
26| `fix` | Bug fix | PATCH |
27| `docs` | Documentation only | - |
28| `style` | Formatting, no code change | - |
29| `refactor` | Neither fix nor feature | - |
30| `perf` | Performance improvement | PATCH |
31| `test` | Adding/correcting tests | - |
32| `build` | Build system, dependencies | - |
33| `ci` | CI configuration | - |
34| `chore` | Other non-src/test changes | - |
35| `revert` | Reverts a previous commit | - |
36
37### Rules
38
391. Description: imperative mood, lowercase, no period, ≤50 chars (72 for body)
402. Scope: noun in parentheses describing affected area, e.g., `feat(api):`, `fix(parser):`, `docs(readme):`
413. Body: explain _what_ and _why_, not _how_ (blank line after description)
424. Footer: use for breaking changes, issue refs, co-authors
435. Breaking changes: append exclamation mark after type/scope OR add `BREAKING CHANGE:` footer (triggers MAJOR)
44 - Example: `feat!:` or `refactor(api)!:`
45 - Use double quotes in shell commands, not single quotes
46
47### Examples
48
49```
50feat: add user authentication
51
52fix: resolve memory leak in data processor
53
54docs: correct spelling of CHANGELOG
55
56feat(lang): add Polish language
57
58fix: prevent racing of requests
59
60Introduce a request id and a reference to latest request.
61Dismiss incoming responses other than from latest request.
62
63Refs: #123
64
65feat!: drop support for Node 14
66
67BREAKING CHANGE: Node 14 has reached end-of-life. Minimum required version is now Node 18.
68
69refactor(api)!: rename endpoints for consistency
70
71/users → /api/users
72/posts → /api/posts
73
74BREAKING CHANGE: All REST endpoints now prefixed with /api
75
76revert: revert "feat: add experimental caching layer"
77
78This reverts commit 676104e.
79The caching implementation caused data inconsistencies in production.
80
81Refs: #456
82```
83
84## Commit Workflow
85
861. `git status` — review all changes
872. `git diff [--staged]` — understand what changed
883. **Analyze grouping** — split if changes are logically independent:
89 - Different types (`feat` + `fix` → 2 commits)
90 - Unrelated areas (frontend + backend for different features → 2 commits)
91 - Keep related changes together (one feature across multiple files → 1
92 commit)
934. **For each logical group:**
94 - Stage specific files: `git add <files>` (never blind `git add .`)
95 - Commit:
96 - Simple: `git commit -m "type(scope): description"`
97 - With body: `git commit -m "type: description" -m "Body paragraph"`
98 - With editor: `git commit` (for complex messages with body/footer)
995. `git status` — verify completion
100
101## Rules
102
103### Pre-commit Checks
104
105Before committing, verify:
106
107- **Secrets**: Exclude `.env`, `credentials.json`, API keys, tokens
108- **Tests**: Run `npm test`, `pytest`, `cargo test`, or project-specific commands
109- **Linting**: Run linters/formatters (`eslint`, `prettier`, `ruff`, etc.)
110- **Hooks**: Check if pre-commit hooks exist (`.git/hooks/pre-commit`)
111- **Unintended files**: Review `git status` output carefully
112
113### Amending
114
115```
116git commit --amend # edit message and content
117git commit --amend --no-edit # keep message, add staged changes
118```
119
120⚠️ Warn user if commit was already pushed (requires `--force`).
121
122### Push
123
124```
125git push # existing upstream
126git push -u origin <branch> # new branch
127```