{
    "content": [
        {
            "type": "text",
            "text": "# git-replace (info)\n\n## NAME\n\ngit-replace - Create, list, delete refs to replace objects\n\n## SYNOPSIS\n\ngit replace [-f] <object> <replacement>\ngit replace [-f] --edit <object>\ngit replace [-f] --graft <commit> [<parent>...]\ngit replace [-f] --convert-graft-file\ngit replace -d <object>...\ngit replace [--format=<format>] [-l [<pattern>]]\n\n## DESCRIPTION\n\nAdds a replace reference in refs/replace/ namespace.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (6 subsections)\n- **FORMATS**\n- **CREATING REPLACEMENT OBJECTS**\n- **BUGS**\n- **SEE ALSO**\n- **GIT**\n- **NOTES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "git-replace",
        "section": "",
        "mode": "info",
        "summary": "git-replace - Create, list, delete refs to replace objects",
        "synopsis": "git replace [-f] <object> <replacement>\ngit replace [-f] --edit <object>\ngit replace [-f] --graft <commit> [<parent>...]\ngit replace [-f] --convert-graft-file\ngit replace -d <object>...\ngit replace [--format=<format>] [-l [<pattern>]]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-f",
                "long": "--force",
                "arg": null,
                "description": "If an existing replace ref for the same object exists, it will be overwritten (instead of failing)."
            },
            {
                "flag": "-d",
                "long": "--delete",
                "arg": null,
                "description": "Delete existing replace refs for the given objects."
            },
            {
                "flag": "",
                "long": "--edit",
                "arg": "<object>",
                "description": "Edit an object's content interactively. The existing content for <object> is pretty-printed into a temporary file, an editor is launched on the file, and the result is parsed to create a new object of the same type as <object>. A replacement ref is then created to replace <object> with the newly created object. See git- var(1) for details about how the editor will be chosen."
            },
            {
                "flag": "",
                "long": "--raw",
                "arg": null,
                "description": "When editing, provide the raw object contents rather than pretty-printed ones. Currently this only affects trees, which will be shown in their binary form. This is harder to work with, but can help when repairing a tree that is so corrupted it cannot be pretty-printed. Note that you may need to configure your editor to cleanly read and write binary data. --graft <commit> [<parent>...] Create a graft commit. A new commit is created with the same content as <commit> except that its parents will be [<parent>...] instead of <commit>'s parents. A replacement ref is then created to replace <commit> with the newly created commit. Use --convert-graft-file to convert a $GITDIR/info/grafts file and use replace refs instead."
            },
            {
                "flag": "",
                "long": "--convert-graft-file",
                "arg": null,
                "description": "Creates graft commits for all entries in $GITDIR/info/grafts and deletes that file upon success. The purpose is to help users with transitioning off of the now-deprecated graft file."
            },
            {
                "flag": "-l",
                "long": "--list",
                "arg": "<pattern>",
                "description": "List replace refs for objects that match the given pattern (or all if no pattern is given). Typing \"git replace\" without arguments, also lists all replace refs. --format=<format> When listing, use the specified <format>, which can be one of short, medium and long. When omitted, the format defaults to short."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "git-hash-object",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-hash-object/1/json"
            },
            {
                "name": "git-rebase",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-rebase/1/json"
            },
            {
                "name": "git-tag",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-tag/1/json"
            },
            {
                "name": "git-branch",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-branch/1/json"
            },
            {
                "name": "git-commit",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-commit/1/json"
            },
            {
                "name": "git-var",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git-var/1/json"
            },
            {
                "name": "git",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/git/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 34,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-f, --force",
                        "lines": 3,
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-d, --delete",
                        "lines": 2,
                        "flag": "-d",
                        "long": "--delete"
                    },
                    {
                        "name": "--edit <object>",
                        "lines": 7,
                        "long": "--edit",
                        "arg": "<object>"
                    },
                    {
                        "name": "--raw",
                        "lines": 15,
                        "long": "--raw"
                    },
                    {
                        "name": "--convert-graft-file",
                        "lines": 4,
                        "long": "--convert-graft-file"
                    },
                    {
                        "name": "-l <pattern>, --list <pattern>",
                        "lines": 8,
                        "flag": "-l",
                        "long": "--list",
                        "arg": "<pattern>"
                    }
                ]
            },
            {
                "name": "FORMATS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "CREATING REPLACEMENT OBJECTS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-replace - Create, list, delete refs to replace objects\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git replace [-f] <object> <replacement>\ngit replace [-f] --edit <object>\ngit replace [-f] --graft <commit> [<parent>...]\ngit replace [-f] --convert-graft-file\ngit replace -d <object>...\ngit replace [--format=<format>] [-l [<pattern>]]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Adds a replace reference in refs/replace/ namespace.\n\nThe name of the replace reference is the SHA-1 of the object that is\nreplaced. The content of the replace reference is the SHA-1 of the\nreplacement object.\n\nThe replaced object and the replacement object must be of the same\ntype. This restriction can be bypassed using -f.\n\nUnless -f is given, the replace reference must not yet exist.\n\nThere is no other restriction on the replaced and replacement objects.\nMerge commits can be replaced by non-merge commits and vice versa.\n\nReplacement references will be used by default by all Git commands\nexcept those doing reachability traversal (prune, pack transfer and\nfsck).\n\nIt is possible to disable use of replacement references for any command\nusing the --no-replace-objects option just after git.\n\nFor example if commit foo has been replaced by commit bar:\n\n$ git --no-replace-objects cat-file commit foo\n\nshows information about commit foo, while:\n\n$ git cat-file commit foo\n\nshows information about commit bar.\n\nThe GITNOREPLACEOBJECTS environment variable can be set to achieve\nthe same effect as the --no-replace-objects option.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-f, --force",
                        "content": "If an existing replace ref for the same object exists, it will be\noverwritten (instead of failing).\n",
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-d, --delete",
                        "content": "Delete existing replace refs for the given objects.\n",
                        "flag": "-d",
                        "long": "--delete"
                    },
                    {
                        "name": "--edit <object>",
                        "content": "Edit an object's content interactively. The existing content for\n<object> is pretty-printed into a temporary file, an editor is\nlaunched on the file, and the result is parsed to create a new\nobject of the same type as <object>. A replacement ref is then\ncreated to replace <object> with the newly created object. See git-\nvar(1) for details about how the editor will be chosen.\n",
                        "long": "--edit",
                        "arg": "<object>"
                    },
                    {
                        "name": "--raw",
                        "content": "When editing, provide the raw object contents rather than\npretty-printed ones. Currently this only affects trees, which will\nbe shown in their binary form. This is harder to work with, but can\nhelp when repairing a tree that is so corrupted it cannot be\npretty-printed. Note that you may need to configure your editor to\ncleanly read and write binary data.\n\n--graft <commit> [<parent>...]\nCreate a graft commit. A new commit is created with the same\ncontent as <commit> except that its parents will be [<parent>...]\ninstead of <commit>'s parents. A replacement ref is then created to\nreplace <commit> with the newly created commit. Use\n--convert-graft-file to convert a $GITDIR/info/grafts file and use\nreplace refs instead.\n",
                        "long": "--raw"
                    },
                    {
                        "name": "--convert-graft-file",
                        "content": "Creates graft commits for all entries in $GITDIR/info/grafts and\ndeletes that file upon success. The purpose is to help users with\ntransitioning off of the now-deprecated graft file.\n",
                        "long": "--convert-graft-file"
                    },
                    {
                        "name": "-l <pattern>, --list <pattern>",
                        "content": "List replace refs for objects that match the given pattern (or all\nif no pattern is given). Typing \"git replace\" without arguments,\nalso lists all replace refs.\n\n--format=<format>\nWhen listing, use the specified <format>, which can be one of\nshort, medium and long. When omitted, the format defaults to short.\n",
                        "flag": "-l",
                        "long": "--list",
                        "arg": "<pattern>"
                    }
                ]
            },
            "FORMATS": {
                "content": "The following format are available:\n\no   short: <replaced sha1>\n\no   medium: <replaced sha1> -> <replacement sha1>\n\no   long: <replaced sha1> (<replaced type>) -> <replacement sha1>\n(<replacement type>)\n",
                "subsections": []
            },
            "CREATING REPLACEMENT OBJECTS": {
                "content": "git-hash-object(1), git-rebase(1), and git-filter-repo[1], among other\ngit commands, can be used to create replacement objects from existing\nobjects. The --edit option can also be used with git replace to create\na replacement object by editing an existing object.\n\nIf you want to replace many blobs, trees or commits that are part of a\nstring of commits, you may just want to create a replacement string of\ncommits and then only replace the commit at the tip of the target\nstring of commits with the commit at the tip of the replacement string\nof commits.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Comparing blobs or trees that have been replaced with those that\nreplace them will not work properly. And using git reset --hard to go\nback to a replaced commit will move the branch to the replacement\ncommit instead of the replaced commit.\n\nThere may be other problems when using git rev-list related to pending\nobjects.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "git-hash-object(1) git-rebase(1) git-tag(1) git-branch(1) git-commit(1)\ngit-var(1) git(1) git-filter-repo[1]\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n",
                "subsections": []
            },
            "NOTES": {
                "content": "1. git-filter-repo\nhttps://github.com/newren/git-filter-repo\n\nGit 2.34.1                        02/26/2026                    GIT-REPLACE(1)",
                "subsections": []
            }
        }
    }
}