【问题标题】:`git notes append` creates additional blank line`git notes append` 创建额外的空行
【发布时间】:2020-02-05 18:16:08
【问题描述】:

假设我有 git commit 和 git note:

commit 385f6c188a5b1cef25acb6412ba4acd7c25b0b9c (HEAD -> master)
Author: zuku
Date:   Tue Oct 8 14:14:31 2019 +0200

    Test commit

Notes:
    Test note

现在我想在此注释中添加更多文本:

git notes append -m "Next line"
git notes append -m "Another line"

问题是每次git notes append 也会添加空行:

commit 385f6c188a5b1cef25acb6412ba4acd7c25b0b9c (HEAD -> master)
Author: zuku
Date:   Tue Oct 8 14:14:31 2019 +0200

    Test commit

Notes:
    Test note

    Next line

    Another line

我没有看到这样做的目的,并且真的很想避免这些空行。我知道我可以使用git notes edit 并手动输入文本,但我需要在不使用编辑器的情况下从命令行执行此操作。我在docs 中没有找到任何有用的信息。 任何想法如何做到这一点?谢谢。

【问题讨论】:

  • 这就是 git notes 应该如何工作的,其目的与英语中的任何段落中断相同。如果你想编辑现有的笔记,习惯用法是使用git commit --amend --edit

标签: git git-notes


【解决方案1】:

使用这个小脚本

# 1 line script:
notes=$(git notes show HEAD); git notes add -f -m"${notes}<YOUR MESSAGE>"

说明

# Get the current note's message and store it in notes variable
# In this sample I'm using HEAD but you can use any commit you wish
notes=$(git notes show HEAD)

# Use the previous not and append the desired extra message to it
# Update the current message using the -f flag so it will overwrite the existing note
git notes add -f -m"${notes}<YOUR MESSAGE>"

【讨论】:

    猜你喜欢
    • 2014-05-05
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2013-04-29
    • 2014-01-28
    • 1970-01-01
    相关资源
    最近更新 更多