Git
English ▾ 主題 ▾ 最新版本 ▾ git-stripspace 最後更新於 2.43.0

名稱

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

概要

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

描述

從標準輸入讀取文字,例如 commit 訊息、註解、標籤和分支描述,並以 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