{
    "mode": "man",
    "parameter": "GIT-STRIPSPACE",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/GIT-STRIPSPACE/json",
    "generated": "2026-11-11T07:30:42Z",
    "synopsis": "git stripspace [-s | --strip-comments]\ngit stripspace [-c | --comment-lines]",
    "sections": {
        "NAME": {
            "content": "git-stripspace - Remove unnecessary whitespace\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git stripspace [-s | --strip-comments]\ngit stripspace [-c | --comment-lines]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Read text, such as commit messages, notes, tags and branch descriptions, from the standard\ninput and clean it in the manner used by Git.\n\nWith no arguments, this will:\n\n•   remove trailing whitespace from all lines\n\n•   collapse multiple consecutive empty lines into one empty line\n\n•   remove empty lines from the beginning and end of the input\n\n•   add a missing \\n to the last line if necessary.\n\nIn the case where the input consists entirely of whitespace characters, no output will be\nproduced.\n\nNOTE: This is intended for cleaning metadata. Prefer the --whitespace=fix mode of git-\napply(1) for correcting whitespace of patches or files in the repository.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-s, --strip-comments",
                    "content": "Skip and remove all lines starting with a comment character (default #).\n",
                    "flag": "-s",
                    "long": "--strip-comments"
                },
                {
                    "name": "-c, --comment-lines",
                    "content": "Prepend the comment character and a blank space to each line. Lines will automatically be\nterminated with a newline. On empty lines, only the comment character will be prepended.\n",
                    "flag": "-c",
                    "long": "--comment-lines"
                }
            ]
        },
        "EXAMPLES": {
            "content": "Given the following noisy input with $ indicating the end of a line:\n\n|A brief introduction   $\n|   $\n|$\n|A new paragraph$\n|# with a commented-out line    $\n|explaining lots of stuff.$\n|$\n|# An old paragraph, also commented-out. $\n|      $\n|The end.$\n|  $\n\n\nUse git stripspace with no arguments to obtain:\n\n|A brief introduction$\n|$\n|A new paragraph$\n|# with a commented-out line$\n|explaining lots of stuff.$\n|$\n|# An old paragraph, also commented-out.$\n|$\n|The end.$\n\n\nUse git stripspace --strip-comments to obtain:\n\n|A brief introduction$\n|$\n|A new paragraph$\n|explaining lots of stuff.$\n|$\n|The end.$\n\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.43.0                                   07/02/2025                            GIT-STRIPSPACE(1)",
            "subsections": []
        }
    },
    "summary": "git-stripspace - Remove unnecessary whitespace",
    "flags": [
        {
            "flag": "-s",
            "long": "--strip-comments",
            "arg": null,
            "description": "Skip and remove all lines starting with a comment character (default #)."
        },
        {
            "flag": "-c",
            "long": "--comment-lines",
            "arg": null,
            "description": "Prepend the comment character and a blank space to each line. Lines will automatically be terminated with a newline. On empty lines, only the comment character will be prepended."
        }
    ],
    "examples": [
        "Given the following noisy input with $ indicating the end of a line:",
        "|A brief introduction   $",
        "|   $",
        "|$",
        "|A new paragraph$",
        "|# with a commented-out line    $",
        "|explaining lots of stuff.$",
        "|$",
        "|# An old paragraph, also commented-out. $",
        "|      $",
        "|The end.$",
        "|  $",
        "Use git stripspace with no arguments to obtain:",
        "|A brief introduction$",
        "|$",
        "|A new paragraph$",
        "|# with a commented-out line$",
        "|explaining lots of stuff.$",
        "|$",
        "|# An old paragraph, also commented-out.$",
        "|$",
        "|The end.$",
        "Use git stripspace --strip-comments to obtain:",
        "|A brief introduction$",
        "|$",
        "|A new paragraph$",
        "|explaining lots of stuff.$",
        "|$",
        "|The end.$"
    ],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Read text (e.g. commit messages, notes, tags, and branch descriptions) from `stdin` and clean it into the manner used by Git.",
        "examples": [
            {
                "description": "Trim whitespace from a file",
                "command": "cat {{path/to/file}} | git stripspace"
            },
            {
                "description": "Trim whitespace and Git comments from a file",
                "command": "cat {{path/to/file}} | git stripspace {{-s|--strip-comments}}"
            },
            {
                "description": "Convert all lines in a file into Git comments",
                "command": "git < {{path/to/file}} stripspace {{-c|--comment-lines}}"
            }
        ]
    }
}