Skip to content

Commits (c*)

The c* commands handle creating and modifying commits, making it easier to record changes in your repository.

Quick Reference

CommandMemory HookSummary
hug cCommit stagedCommit staged changes
hug caCommit All trackedCommit ALL tracked changes
hug caaCommit Add AllStage and commit ALL changes (tracked + untracked)
hug cmCommit ModifyModify (amend) last commit with staged changes only
hug cmaCommit Modify trackedModify (amend) last commit with all tracked changes
hug ccCommit Cherry-pickCopy a commit from another branch onto HEAD

hug c

Commit staged changes.

Usage: hug c

Examples:

shell
hug c # A text editor will be shown so that you can add a message
hug c -m "Fix typo in README"

This is a safe way to commit, ensuring only staged files are included.

hug ca

Commit all tracked changes.

Usage: hug ca

Examples:

shell
hug ca # A text editor will be shown so that you can add a message
hug ca -m "Fix typo in README"

This is a quick way to commit without having to add files to the staging area first. Useful if you know that ALL tracked files must be committed.

hug caa

Stage and commit all changes (tracked and untracked).

Usage: hug caa

Examples:

shell
hug caa -m "Add new feature with all related files"

Stages all current changes (staged and unstaged) and creates a new commit. It is a convenient shortcut for hug aa && hug c.

hug cm

Modify (amend) the last commit with staged changes.

This command allows you to add staged changes to the previous commit without creating a new one. It's ideal for fixing small mistakes or adding forgotten files.

When you run hug cm without flags, your editor will open with the previous commit message already populated. This is very convenient if you just need to fix a typo or slightly reword the message.

If you want to replace the old message entirely, you can provide a new one directly with the -m flag, which avoids opening the editor.

Usage: hug cm

Examples:

shell
# Realize you forgot to add a file to the last commit
hug a docs/forgotten-file.md
# Open the editor to see the last message and confirm or tweak it
hug cm

# Or... Replace the last commit message entirely without opening the editor
hug cm -m "A completely new and corrected commit message"

hug cma

Modify (amend) the last commit with all tracked changes.

Similar to hug cm, this command amends the last commit. However, it automatically includes all changes to ALL tracked files, so you don't need to stage them first.

Running hug cma opens your editor with the existing commit message, making it perfect for small edits. To replace the message entirely without opening the editor, use the -m flag.

Usage: hug cma

Examples:

shell
# After committing, you make a quick change to a file you just committed
# Open the editor to adjust the commit message
hug cma

# Amend and provide a new message in one step
hug cma -m "Add new feature (with all files)"

hug cc

Copy a commit from another branch onto the current branch (cherry-pick).

Usage: hug cc <commit>

Examples:

shell
hug cc a1b2c3d4  # Apply the changes from commit a1b2c3d4 to the tip (HEAD) of the current branch

Applies the changes from a specific commit on top of the current HEAD, creating a new commit on the current branch. hug also adds the original commit hash to the new commit message for reference. This is useful for bringing a specific bug fix or feature from one branch to another without merging the entire source branch.

Tips

  • Use hug s or hug sl to check what you are about to commit, especially before using hug c.
  • hug ca and hug caa are great for speed, but be sure you want to commit all changes. For more selective commits, stage files individually with hug a or hug aa and then use hug c.
  • Use hug cm or hug cma to fix mistakes in your last commit (e.g., forgotten changes or typos in the message) without creating extra "fixup" commits. This keeps your history cleaner.

WARNING

Avoid using hug cm or hug cma on commits that have already been pushed to a remote repository (like GitHub). Amending rewrites history, which can create significant problems for anyone who has already pulled your changes.

Released under the Apache 2.0 License.