Skip to content

Command: git record

Waleed Khan edited this page Feb 10, 2023 · 13 revisions

Description

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

git record behaves differently than git commit with respect to staged changes. 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.

Committing to a new branch

To start a new branch, run git record with the -b/--branch 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.

Committing to a new branchless commit stack

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.

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.

Clone this wiki locally