{
    "content": [
        {
            "type": "text",
            "text": "# GIT-REVERT (man)\n\n## NAME\n\ngit-revert - Revert some existing commits\n\n## SYNOPSIS\n\ngit revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...\ngit revert (--continue | --skip | --abort | --quit)\n\n## DESCRIPTION\n\nGiven one or more existing commits, revert the changes that the related patches introduce,\nand record some new commits that record them. This requires your working tree to be clean (no\nmodifications from the HEAD commit).\n\n## TLDR\n\n> Create new commits which reverse the effect of earlier ones.\n\n- Revert the most recent commit:\n  `git revert HEAD`\n- Revert the 5th last commit:\n  `git revert HEAD~4`\n- Revert a specific commit:\n  `git revert {{0c01a9}}`\n- Revert multiple commits:\n  `git revert {{branch_name~5}}..{{branch_name~2}}`\n- Don't create new commits, just change the working tree:\n  `git revert {{-n|--no-commit}} {{0c01a9}}..{{9a1743}}`\n- Cancel a Git revert after a merge conflict:\n  `git revert --abort`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (5 subsections)\n- **SEQUENCER SUBCOMMANDS** (4 subsections)\n- **EXAMPLES** (2 subsections)\n- **SEE ALSO**\n- **GIT**\n- **NOTES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "GIT-REVERT",
        "section": "",
        "mode": "man",
        "summary": "git-revert - Revert some existing commits",
        "synopsis": "git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...\ngit revert (--continue | --skip | --abort | --quit)",
        "tldr_summary": "Create new commits which reverse the effect of earlier ones.",
        "tldr_examples": [
            {
                "description": "Revert the most recent commit",
                "command": "git revert HEAD"
            },
            {
                "description": "Revert the 5th last commit",
                "command": "git revert HEAD~4"
            },
            {
                "description": "Revert a specific commit",
                "command": "git revert {{0c01a9}}"
            },
            {
                "description": "Revert multiple commits",
                "command": "git revert {{branch_name~5}}..{{branch_name~2}}"
            },
            {
                "description": "Don't create new commits, just change the working tree",
                "command": "git revert {{-n|--no-commit}} {{0c01a9}}..{{9a1743}}"
            },
            {
                "description": "Cancel a Git revert after a merge conflict",
                "command": "git revert --abort"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-e",
                "long": "--edit",
                "arg": null,
                "description": "With this option, git revert will let you edit the commit message prior to committing the revert. This is the default if you run the command from a terminal. -m parent-number, --mainline parent-number Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse the change relative to the specified parent. Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want. See the revert-a-faulty-merge How-To[1] for more details."
            },
            {
                "flag": "",
                "long": "--no-edit",
                "arg": null,
                "description": "With this option, git revert will not start the commit message editor. --cleanup=<mode> This option determines how the commit message will be cleaned up before being passed on to the commit machinery. See git-commit(1) for more details. In particular, if the <mode> is given a value of scissors, scissors will be appended to MERGEMSG before being passed on in the case of a conflict."
            },
            {
                "flag": "-n",
                "long": "--no-commit",
                "arg": null,
                "description": "Usually the command automatically creates some commits with commit log messages stating which commits were reverted. This flag applies the changes necessary to revert the named commits to your working tree and the index, but does not make the commits. In addition, when this option is used, your index does not have to match the HEAD commit. The revert is done against the beginning state of your index. This is useful when reverting more than one commits' effect to your index in a row. -S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign GPG-sign commits. The keyid argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. --no-gpg-sign is useful to countermand both commit.gpgSign configuration variable, and earlier --gpg-sign."
            },
            {
                "flag": "-s",
                "long": "--signoff",
                "arg": null,
                "description": "Add a Signed-off-by trailer at the end of the commit message. See the signoff option in git-commit(1) for more information. --strategy=<strategy> Use the given merge strategy. Should only be used once. See the MERGE STRATEGIES section in git-merge(1) for details. -X<option>, --strategy-option=<option> Pass the merge strategy-specific option through to the merge strategy. See git-merge(1) for details."
            },
            {
                "flag": "",
                "long": "--no-rerere-autoupdate",
                "arg": null,
                "description": "Allow the rerere mechanism to update the index with the result of auto-conflict resolution if possible."
            }
        ],
        "examples": [
            "Revert the changes specified by the fourth last commit in HEAD and create a new commit",
            "with the reverted changes.",
            "Revert the changes done by commits from the fifth last commit in master (included) to the",
            "third last commit in master (included), but do not create any commit with the reverted",
            "changes. The revert only modifies the working tree and the index."
        ],
        "see_also": [
            {
                "name": "git-cherry-pick",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-cherry-pick/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 5,
                "subsections": [
                    {
                        "name": "-e, --edit",
                        "lines": 15,
                        "flag": "-e",
                        "long": "--edit"
                    },
                    {
                        "name": "--no-edit",
                        "lines": 8,
                        "long": "--no-edit"
                    },
                    {
                        "name": "-n, --no-commit",
                        "lines": 13,
                        "flag": "-n",
                        "long": "--no-commit"
                    },
                    {
                        "name": "-s, --signoff",
                        "lines": 11,
                        "flag": "-s",
                        "long": "--signoff"
                    },
                    {
                        "name": "--rerere-autoupdate, --no-rerere-autoupdate",
                        "lines": 3,
                        "long": "--no-rerere-autoupdate"
                    }
                ]
            },
            {
                "name": "SEQUENCER SUBCOMMANDS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "--continue",
                        "lines": 3,
                        "long": "--continue"
                    },
                    {
                        "name": "--skip",
                        "lines": 2,
                        "long": "--skip"
                    },
                    {
                        "name": "--quit",
                        "lines": 3,
                        "long": "--quit"
                    },
                    {
                        "name": "--abort",
                        "lines": 2,
                        "long": "--abort"
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 1,
                "subsections": [
                    {
                        "name": "git revert HEAD~3",
                        "lines": 3
                    },
                    {
                        "name": "git revert -n master~5..master~2",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-revert - Revert some existing commits\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...\ngit revert (--continue | --skip | --abort | --quit)\n\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Given one or more existing commits, revert the changes that the related patches introduce,\nand record some new commits that record them. This requires your working tree to be clean (no\nmodifications from the HEAD commit).\n\nNote: git revert is used to record some new commits to reverse the effect of some earlier\ncommits (often only a faulty one). If you want to throw away all uncommitted changes in your\nworking directory, you should see git-reset(1), particularly the --hard option. If you want\nto extract specific files as they were in another commit, you should see git-restore(1),\nspecifically the --source option. Take care with these alternatives as both will discard\nuncommitted changes in your working directory.\n\nSee \"Reset, restore and revert\" in git(1) for the differences between the three commands.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "<commit>...\nCommits to revert. For a more complete list of ways to spell commit names, see\ngitrevisions(7). Sets of commits can also be given but no traversal is done by default,\nsee git-rev-list(1) and its --no-walk option.\n",
                "subsections": [
                    {
                        "name": "-e, --edit",
                        "content": "With this option, git revert will let you edit the commit message prior to committing the\nrevert. This is the default if you run the command from a terminal.\n\n-m parent-number, --mainline parent-number\nUsually you cannot revert a merge because you do not know which side of the merge should\nbe considered the mainline. This option specifies the parent number (starting from 1) of\nthe mainline and allows revert to reverse the change relative to the specified parent.\n\nReverting a merge commit declares that you will never want the tree changes brought in by\nthe merge. As a result, later merges will only bring in tree changes introduced by\ncommits that are not ancestors of the previously reverted merge. This may or may not be\nwhat you want.\n\nSee the revert-a-faulty-merge How-To[1] for more details.\n",
                        "flag": "-e",
                        "long": "--edit"
                    },
                    {
                        "name": "--no-edit",
                        "content": "With this option, git revert will not start the commit message editor.\n\n--cleanup=<mode>\nThis option determines how the commit message will be cleaned up before being passed on\nto the commit machinery. See git-commit(1) for more details. In particular, if the <mode>\nis given a value of scissors, scissors will be appended to MERGEMSG before being passed\non in the case of a conflict.\n",
                        "long": "--no-edit"
                    },
                    {
                        "name": "-n, --no-commit",
                        "content": "Usually the command automatically creates some commits with commit log messages stating\nwhich commits were reverted. This flag applies the changes necessary to revert the named\ncommits to your working tree and the index, but does not make the commits. In addition,\nwhen this option is used, your index does not have to match the HEAD commit. The revert\nis done against the beginning state of your index.\n\nThis is useful when reverting more than one commits' effect to your index in a row.\n\n-S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign\nGPG-sign commits. The keyid argument is optional and defaults to the committer identity;\nif specified, it must be stuck to the option without a space.  --no-gpg-sign is useful to\ncountermand both commit.gpgSign configuration variable, and earlier --gpg-sign.\n",
                        "flag": "-n",
                        "long": "--no-commit"
                    },
                    {
                        "name": "-s, --signoff",
                        "content": "Add a Signed-off-by trailer at the end of the commit message. See the signoff option in\ngit-commit(1) for more information.\n\n--strategy=<strategy>\nUse the given merge strategy. Should only be used once. See the MERGE STRATEGIES section\nin git-merge(1) for details.\n\n-X<option>, --strategy-option=<option>\nPass the merge strategy-specific option through to the merge strategy. See git-merge(1)\nfor details.\n",
                        "flag": "-s",
                        "long": "--signoff"
                    },
                    {
                        "name": "--rerere-autoupdate, --no-rerere-autoupdate",
                        "content": "Allow the rerere mechanism to update the index with the result of auto-conflict\nresolution if possible.\n",
                        "long": "--no-rerere-autoupdate"
                    }
                ]
            },
            "SEQUENCER SUBCOMMANDS": {
                "content": "",
                "subsections": [
                    {
                        "name": "--continue",
                        "content": "Continue the operation in progress using the information in .git/sequencer. Can be used\nto continue after resolving conflicts in a failed cherry-pick or revert.\n",
                        "long": "--continue"
                    },
                    {
                        "name": "--skip",
                        "content": "Skip the current commit and continue with the rest of the sequence.\n",
                        "long": "--skip"
                    },
                    {
                        "name": "--quit",
                        "content": "Forget about the current operation in progress. Can be used to clear the sequencer state\nafter a failed cherry-pick or revert.\n",
                        "long": "--quit"
                    },
                    {
                        "name": "--abort",
                        "content": "Cancel the operation and return to the pre-sequence state.\n",
                        "long": "--abort"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "",
                "subsections": [
                    {
                        "name": "git revert HEAD~3",
                        "content": "Revert the changes specified by the fourth last commit in HEAD and create a new commit\nwith the reverted changes.\n"
                    },
                    {
                        "name": "git revert -n master~5..master~2",
                        "content": "Revert the changes done by commits from the fifth last commit in master (included) to the\nthird last commit in master (included), but do not create any commit with the reverted\nchanges. The revert only modifies the working tree and the index.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "git-cherry-pick(1)\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n",
                "subsections": []
            },
            "NOTES": {
                "content": "1. revert-a-faulty-merge How-To\nfile:///usr/share/doc/git/html/howto/revert-a-faulty-merge.html\n\n\n\nGit 2.34.1                                   02/26/2026                                GIT-REVERT(1)",
                "subsections": []
            }
        }
    }
}