blob: abcd8e1076f01a19f250ea33b0306e8d8a93b47f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<h1>git-stripspace</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-stripspace - Remove unnecessary whitespace</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git stripspace [-s | --strip-comments]
git stripspace [-c | --comment-lines]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read text, such as commit messages, notes, tags and branch descriptions, from the standard input and clean it in the manner used by Git.</p> <p>With no arguments, this will:</p> <div class="ulist"> <ul> <li> <p>remove trailing whitespace from all lines</p> </li> <li> <p>collapse multiple consecutive empty lines into one empty line</p> </li> <li> <p>remove empty lines from the beginning and end of the input</p> </li> <li> <p>add a missing <code>\n</code> to the last line if necessary.</p> </li> </ul> </div> <p>In the case where the input consists entirely of whitespace characters, no output will be produced.</p> <p><strong>NOTE</strong>: This is intended for cleaning metadata. Prefer the <code>--whitespace=fix</code> mode of <a href="git-apply">git-apply[1]</a> for correcting whitespace of patches or files in the repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stripspace.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-stripspace.txt---strip-comments"> --strip-comments </dt> <dd> <p>Skip and remove all lines starting with a comment character (default <code>#</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-stripspace.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-stripspace.txt---comment-lines"> --comment-lines </dt> <dd> <p>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.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Given the following noisy input with <code>$</code> indicating the end of a line:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction $
| $
|$
|A new paragraph$
|# with a commented-out line $
|explaining lots of stuff.$
|$
|# An old paragraph, also commented-out. $
| $
|The end.$
| $</pre> </div> </div> <p>Use <code>git stripspace</code> with no arguments to obtain:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction$
|$
|A new paragraph$
|# with a commented-out line$
|explaining lots of stuff.$
|$
|# An old paragraph, also commented-out.$
|$
|The end.$</pre> </div> </div> <p>Use <code>git stripspace --strip-comments</code> to obtain:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction$
|$
|A new paragraph$
|explaining lots of stuff.$
|$
|The end.$</pre> </div> </div> </div><div class="_attribution">
<p class="_attribution-p">
© 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br>
<a href="https://git-scm.com/docs/git-stripspace" class="_attribution-link">https://git-scm.com/docs/git-stripspace</a>
</p>
</div>
|