Commands

chamoji commit

commit.mdEdit on GitHub

Write a commit with the composer. It asks for a gitmoji, a scope, a title, a body, why you made the change and whether it breaks anything, then commits what you staged. The changelog can sort a commit like this on its own.

CHANGES YOUR REPO MONOREPO-AWARE

The composer needs a terminal. In a script or CI, use git commit -m.

CHANGES YOUR REPOchamoji commit

What it does, in order

  1. Opens the composer. On the terminal, even when stdin isn’t one, as in a git hook. With no terminal at all it stops and exits 2.
  2. Asks. A gitmoji from a search list, then the scope, the title, a body, why, and whether it breaks anything. Enter moves on, Esc goes back and Ctrl-C cancels.
  3. Stamps the workstream. When a workstream is active in this worktree, it adds its Workstream: line.
  4. Commits. With git commit, so your git hooks and settings apply. It prints what git prints.

The questions

  • Name
    Gitmoji
    Description

    Type bug, fix or a few letters such as spk, and pick with the arrow keys. With Jev’s suggestions turned on, its three likeliest gitmojis show above the list, or at the top of it when Jev is very sure.

  • Name
    Scope
    Type
    optional
    Description

    Written as (scope): after the gitmoji. Skipped when scopePrompt is false.

  • Name
    Title
    Description

    The rest of the subject line. Its first letter is capitalized unless capitalizeTitle is false.

  • Name
    Body
    Type
    optional
    Description

    More lines after the subject. Skipped when messagePrompt is false.

  • Name
    Why?
    Type
    optional
    Description

    Kept as a Why: trailer, so chamoji why and project memory can find it later.

  • Name
    Breaking change?
    Type
    y/N
    Description

    No by default. Yes asks what breaks, and adds a BREAKING CHANGE: trailer with your answer, or the title when you leave it empty.

In a repo with release units, a line under the header says which units the staged change releases with, and which it only rides along to. When it releases none of its own, a last question offers to release those units now, with a Release: trailer for each.

The settings come from .gitmojirc.json, or the gitmoji key in package.json, as gitmoji-cli reads them. emojiFormat: "code" writes :sparkles: instead of ✨, and autoAdd stages everything first. Config lists them with their defaults.

Arguments

chamoji commit takes no arguments.

Flags

  • Name
    --all, -a
    Type
    boolean
    Description

    Commit every change to tracked files, as git commit -a does, not only what you staged. New files still need git add. With autoAdd set, every change is staged first either way.

  • Name
    --no-update-check
    Type
    boolean
    Description

    Don’t check npm for a newer chamoji. See the update notice.

Common combinations

chamoji commit

Commit what you staged.

chamoji commit -a

Commit every change to tracked files.

chamoji hook install

Open the same composer on a plain git commit.

Output

These are from real runs in a small repo called widgets. The composer draws in place; each block is one screen.

Typing bug narrows the list:

Gitmoji

 chamoji commit  Enter next · Esc back · Ctrl-C cancel

 Gitmoji › bug
 ❯ 🐛 bug                         Fix a bug.
   🏗️ building_construction       Make architectural changes.

The subject line builds up under the header as you answer. On the last question, Enter takes the default, No, and git commits:

Breaking change?

 chamoji commit  Enter next · Esc back · Ctrl-C cancel
 🐛 (picker): Keep the month when a range is cleared

 Breaking change? (y/N) ›
[main ed9b8a1] 🐛 (picker): Keep the month when a range is cleared
 1 file changed, 1 insertion(+)

The answer to “Why?” is a trailer:

git log -1 --format=%B

🐛 (picker): Keep the month when a range is cleared

Why: Clearing a range jumped back to today

In a repo with two apps, a fix to the shared packages/ui releases neither app on its own, so the composer offers to release both:

Release mobile, web now?

 chamoji commit  Enter next · Esc back · Ctrl-C cancel
 rides along to: mobile, web
 🐛 (ui): Keep the button label on one line

 Release mobile, web now? (y/N) ›
[main 1e23054] 🐛 (ui): Keep the button label on one line
 1 file changed, 1 insertion(+)

Yes adds the trailers:

git log -1 --format=%B

🐛 (ui): Keep the button label on one line

Release: mobile
Release: web

Ctrl-C at any point commits nothing:

Ctrl-C

Cancelled; nothing was committed.

Without a terminal:

chamoji commit

chamoji: commit needs a terminal to ask on; in scripts, use git commit -m

Exit codes

  • Name
    0
    Description
    It committed.
  • Name
    2
    Description
    There is no terminal to ask on.
  • Name
    1
    Description

    You cancelled, git refused the commit, or this isn’t a git repo.

Exit codes has every command’s codes.

Was this page helpful?