English ▾ 主题 ▾ 最新版本 ▾ git-stripspace 上次更新于 2.43.0

名称

git-stripspace - 移除不必要的空格

概要

git stripspace [-s | --strip-comments]
git stripspace [-c | --comment-lines]

描述

从标准输入读取文本,例如提交消息、注释、标签和分支描述,并以 Git 使用的方式清理它。

不带参数,这将会

  • 移除所有行尾的空格

  • 将多个连续的空行折叠成一个空行

  • 移除输入开头和结尾的空行

  • 如果需要,在最后一行添加缺少的\n

如果输入完全由空格字符组成,则不会产生任何输出。

注意:这旨在清理元数据。 首选 git-apply[1]--whitespace=fix 模式来纠正存储库中补丁或文件的空格。

选项

-s
--strip-comments

跳过并删除所有以注释字符(默认#)开头的行。

-c
--comment-lines

在每行前面加上注释字符和一个空格。行将自动以换行符结尾。在空行上,只会加上注释字符。

示例

给定以下嘈杂的输入,其中$表示行尾

|A brief introduction   $
|   $
|$
|A new paragraph$
|# with a commented-out line    $
|explaining lots of stuff.$
|$
|# An old paragraph, also commented-out. $
|      $
|The end.$
|  $

使用不带参数的git stripspace来获得

|A brief introduction$
|$
|A new paragraph$
|# with a commented-out line$
|explaining lots of stuff.$
|$
|# An old paragraph, also commented-out.$
|$
|The end.$

使用git stripspace --strip-comments来获得

|A brief introduction$
|$
|A new paragraph$
|explaining lots of stuff.$
|$
|The end.$

GIT

属于 git[1] 套件的一部分

scroll-to-top