Skip to content

Command: git record

kain88-de edited this page May 4, 2024 · 13 revisions

Description

Available since v0.4.0.

git record is a replacement for git add and git commit.

Usage

To commit the unstaged changes in your working copy, run git record. You can pass the -m/--message option to specify a commit message on the command-line. If no commit message is provided, your editor is opened to specify a commit message, similar to git commit. This may change in the future, in that git record may auto-generate a commit message if you don't provide one.

You don't need to stage your changes before committing them; git record behaves differently than git commit in that respect. In general, it doesn't expect that you stage your changes before committing them, although it supports it for compatibility with Git:

  • When running git record with staged changes, those staged changes will be committed.
  • Otherwise, if there are no staged changes, all unstaged changes will be committed.
    • This is similar to git commit -a.
    • This does not include changes to untracked files. You will still need to stage those with git add.
  • To commit just a subset of changes (as if you staged them), select the changes interactively (see below).
    • This is similar to git commit --interactive/git commit --patch, but with a TUI.

To update the contents of an existing commit, see git amend. To update the message of an existing commit, see git reword.

Interactively selecting changes to commit

To commit a subset of your unstaged changes, run git record with the -i/--interactive option. This will open a TUI to interactively select lines to include in the commit. Unselected lines will remain as unstaged changes in the working copy.

Warning: The interactive commit interface is not complete, and doesn't support some use-cases, such as binary or moved files. You should only use it for simple interactive selection.

Committing to a new branch

To start a new branch, run git record with the -c/--create option to create a new branch with the provided name and commit to it. If the branch already exists, an error is produced and the commit is aborted.

Changed in v0.7.0: The -c/--create option used to be called -b/--branch.

Committing to a new commit stack with no associated branch

Oftentimes, you may want to start a new line of development without modifying the current branch (such as if you are on the main branch and don't want to commit to it directly). To first detach from the current branch, run git record with the -d/--detach option.

Inserting the new commit into the current commit stack

Sometimes, you may want to go back to a previous location in the commit stack and add a new commit. To do so, you can run git sw <previous commit> (or git prev, etc.), then run git record with the -I/--insert option. All child commits in the stack will be moved on top of the newly-created commit.

To insert a commit before other commits after it's already been made, see Insert a commit in a stack.

Clone this wiki locally