我有一個多行變數$foo,想用它來標記我的最新提交。我希望這些換行符出現在 git (/github) 中。我試過了
git tag -a v$MAJVER.$MINVER.$PATVER.$HOTVER -m $"$foo"

我怎樣才能(通過bash)使換行符在推動中幸存下來?
uj5u.com熱心網友回復:
只需使用簡單的雙引號。如果這不起作用,那么它的價值。
如果您關心的是提交的輸出,那只是一份報告。
去看看實際的日志。
$: ls -l
total 4
-rwxr-xr-x 1 P2759474 1049089 474 Nov 2 14:22 tst
$: mv tst new
$: git status
On branch tst
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: tst
Untracked files:
(use "git add <file>..." to include in what will be committed)
new
no changes added to commit (use "git add" and/or "git commit -a")
$: foo="
testing
multiline
git
commit
message
"
$: git add .
warning: LF will be replaced by CRLF in new.
The file will have its original line endings in your working directory
$: git commit -m "$foo" # keeps newlines, but shows without them
[tst 74428e6] testing multiline git commit message
1 file changed, 0 insertions( ), 0 deletions(-)
rename tst => new (100%)
$: git log -1
commit 74428e60d830c417ded3ad2c331f02e73319b862 (HEAD -> tst)
Author: Paul Hodges <[email protected]>
Date: Thu Nov 3 10:20:33 2022 -0500
testing
multiline
git
commit
message
標簽也是如此,但您必須知道如何取回資料。
$: git tag -a example -m "$foo"
$: git tag -l
example
$: git tag -n
example testing
$: git tag -n99
example testing
multiline
git
commit
message
你必須告訴它你愿意讓它顯示給你多少行資訊。默認值為 1。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/528135.html
標籤:重击混帐github标签
