首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

git stripspace

名称

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

概要

代码语言:javascript
复制
git stripspace [-s | --strip-comments]
git stripspace [-c | --comment-lines]

描述

从标准输入中读取提交消息,注释,标记和分支描述等文本,并按照 Git 使用的方式进行清理。

没有任何争论,这将会:

  • remove trailing whitespace from all lines
  • collapse multiple consecutive empty lines into one empty line
  • remove empty lines from the beginning and end of the input
  • add a missing \n to the last line if necessary.

在输入完全由空白字符组成的情况下,不会产生输出。

注意:这是为了清理元数据,更喜欢 git-apply [1] 的--whitespace=fix模式来修正版本库中补丁或文件的空白。

选项

-s --strip-comments

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

-c --comment-lines

在每行上添加注释字符和空白。行将自动以换行符终止。在空行上,只有注释字符会被预置。

示例

鉴于以下带有噪音的输入,$指示行的结尾:

代码语言:javascript
复制
|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无参数来获取:

代码语言:javascript
复制
|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获得:

代码语言:javascript
复制
|A brief introduction$
|$
|A new paragraph$
|explaining lots of stuff.$
|$
|The end.$

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com