---
name: git-conventions
description: Git conventions for teams including conventional commits, branching strategies, PR workflows, merge strategies, and commit message formatting. Use when writing commit messages, creating branches, setting up Git workflows, or when the user asks about Git conventions, commit formats, branching strategies, or PR best practices.
title: git-conventions
canonical_url: https://skilld.dev/gh/grahamcrackers/skills/git-conventions
last_updated: 2026-10-07T02:20:44.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install grahamcrackers/skills/git-conventions`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/git-conventions`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/grahamcrackers/skills/git-conventions) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/git-conventions`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/git-conventions --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/git-conventions --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Git Conventions

## Conventional Commits

Format: `<type>(<scope>): <description>`

```
feat(auth): add OAuth2 login with Google
fix(api): handle null response from user endpoint
docs(readme): add deployment instructions
refactor(hooks): extract shared fetch logic into useApi
test(auth): add integration tests for login flow
chore(deps): update react to v19.1
```

### Types

| Type       | When to Use                                             |
| ---------- | ------------------------------------------------------- |
| `feat`     | New feature or capability                               |
| `fix`      | Bug fix                                                 |
| `docs`     | Documentation only                                      |
| `style`    | Formatting, whitespace (no logic change)                |
| `refactor` | Code change that neither fixes a bug nor adds a feature |
| `perf`     | Performance improvement                                 |
| `test`     | Adding or updating tests                                |
| `build`    | Build system or external dependencies                   |
| `ci`       | CI/CD configuration                                     |
| `chore`    | Maintenance tasks, tooling                              |
| `revert`   | Reverts a previous commit                               |

### Rules

- **Type** is required and lowercase.
- **Scope** is optional, lowercase, describes the area of change (`auth`, `api`, `ui`, `deps`).
- **Description** is required, imperative mood ("add", not "added" or "adds"), lowercase, no period at the end.
- **Body** (optional) explains _why_, not _what_. Wrap at 72 characters.
- **Breaking changes**: add `!` after the type/scope or include `BREAKING CHANGE:` in the footer.

```
feat(api)!: change authentication to use JWT tokens

BREAKING CHANGE: The session-based auth endpoints have been removed.
Clients must now use Bearer tokens in the Authorization header.
```

### Multi-Line Commits

```
fix(payments): prevent duplicate charge on retry

The retry logic was not checking if the original charge succeeded
before attempting a new one. Added idempotency key validation
to the charge endpoint.

Closes #1234
```

## Branching Strategy

### Branch Naming

```
feature/add-user-dashboard
fix/null-pointer-in-checkout
chore/upgrade-dependencies
docs/api-authentication-guide
refactor/extract-payment-service
```

Pattern: `<type>/<short-description>` using kebab-case.

### Trunk-Based Development (Recommended)

```
main ─────●────●────●────●────●─────
           \       /      \       /
            ●────●          ●────●
          feature/x       fix/y
```

- `main` is always deployable.
- Short-lived feature branches (1-3 days).
- Merge via squash or rebase to keep history linear.
- Use feature flags for long-running work instead of long-lived branches.

### Git Flow (When Required)

```
main    ─────●──────────────●───────
              \            /
develop ───●───●───●───●───●────●───
            \     /     \     /
             ●───●       ●───●
           feature/x   feature/y
```

- `main` — production releases.
- `develop` — integration branch.
- `feature/*` — branch from develop, merge back to develop.
- `release/*` — stabilization before production.
- `hotfix/*` — urgent fixes from main.

Use trunk-based development unless the project specifically requires Git Flow.

## Commit Best Practices

- **Atomic commits**: Each commit is one logical change that compiles and passes tests.
- **Commit often**: Small, frequent commits are easier to review, bisect, and revert.
- **Don't commit generated files**: Add build outputs, lock files changes (when unintended), and artifacts to `.gitignore`.
- **Don't commit secrets**: Never commit `.env`, API keys, credentials, or tokens.
- **Sign commits**: Use `git commit -S` for verified authorship.

## Pull Request Conventions

### PR Title

Follow the same conventional commit format:

```
feat(dashboard): add real-time notifications widget
fix(auth): resolve token refresh race condition
```

### PR Description Template

```markdown
## Summary

Brief description of what this PR does and why.

## Changes

- Added notification WebSocket connection
- Created NotificationBell component
- Updated header layout to include notifications

## Testing

- [ ] Unit tests pass
- [ ] Manual testing in staging
- [ ] Tested on mobile viewport

## Screenshots

(if applicable)
```

### PR Best Practices

- Keep PRs small (< 400 lines of diff when possible).
- One concern per PR — don't mix refactoring with feature work.
- Self-review before requesting reviews.
- Respond to all review comments, even if just "Done" or "Won't fix because...".
- Squash merge to keep main history clean.

## Merge Strategies

| Strategy     | When to Use                                          | Result                              |
| ------------ | ---------------------------------------------------- | ----------------------------------- |
| Squash merge | Feature branches to main                             | One clean commit per feature        |
| Rebase merge | When you want linear history with individual commits | Flat history, each commit preserved |
| Merge commit | When branch history matters (release branches)       | Explicit merge point                |

**Default recommendation**: Squash merge for feature branches into main. This gives a clean, bisectable history where each commit represents one complete feature or fix.

## .gitignore Essentials

```gitignore
# Dependencies
node_modules/

# Build output
dist/
build/
.next/
out/

# Environment
.env
.env.local
.env.*.local

# IDE
.vscode/settings.json
.idea/

# OS
.DS_Store
Thumbs.db

# Debug
*.log
npm-debug.log*

# Test coverage
coverage/
```

## Useful Aliases

```shell
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm "commit -m"
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --decorate -20"
git config --global alias.amend "commit --amend --no-edit"
git config --global alias.unstage "reset HEAD --"
```
