簡體中文 ▾ 主題 ▾ 最新版本 ▾ git-stripspace 最後更新於 2.50.0

名稱

git-stripspace - 移除不必要的空白字元

概要

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

描述

從標準輸入讀取文字,例如提交訊息、備註、標籤和分支描述,並以 Git 使用的方式進行清理。

不帶任何引數時,這將會

  • 移除所有行末尾的空白字元

  • 將多個連續的空行合併為一個空行

  • 移除輸入開頭和末尾的空行

  • 如果需要,在最後一行新增一個缺失的 \n

如果輸入完全由空白字元組成,則不會產生任何輸出。

注意:這旨在清理元資料。對於更正倉庫中補丁或檔案的空白字元,請優先使用 git-apply[1]--whitespace=fix 模式。

選項

-s
--strip-comments

跳過並移除所有以註釋字元(core.commentChar,預設為 #)開頭的行。

-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