grit revert <commit>
Description
Creates a new commit on the current branch that undoes the changes introduced by <commit>. The revert commit uses the standard Revert "…" subject and a This reverts commit <oid>. body, matching what Git writes with git revert --no-edit.
<commit> can be a full or short commit id, a branch name (to revert the commit at its tip) or an expression like HEAD~1.
grit revert works on one commit at a time. It refuses, and changes nothing, when:
- you have uncommitted changes, or the current branch has no commits, or HEAD is detached
<commit>is a merge commit- the revert would conflict with the current branch; the conflicting files are listed
- an untracked file would be replaced by a path the revert would check out (same rule as
grit switch)
There is no range revert and no --no-commit mode.
Options
| Option | Description |
|---|---|
<commit> |
The commit to undo on the current branch. |
JSON output
Pass --json for stable, scripting-friendly output:
| Field | Type | Meaning |
|---|---|---|
source |
string | Full id of the commit that was reverted. |
oid |
string | Full id of the new revert commit on the current branch. |
subject |
string | Subject line of the revert commit (for example Revert "Add feature"). |