代码之家  ›  专栏  ›  技术社区  ›  knittl

用hashmark(#)启动git提交消息

  •  238
  • knittl  · 技术社区  · 14 年前

    Git处理以 #

    #123 salt hashed passwords
    

    git只需从提交消息中删除该行。有没有什么办法可以摆脱这种混乱?我试过了 \ ! #

    8 回复  |  直到 14 年前
        1
  •  260
  •   CB Bailey    14 年前

    这种行为是 git commit 的默认“清理”行为。如果你想保持台词以 # 您可以使用另一种清理模式。

    例如。

    git commit --cleanup=whitespace
    

    如果你这样做,你必须小心删除所有 # 不希望出现在提交中的行。

        2
  •  153
  •   Community CDub    4 年前

    注意,因为 git1.8.2 (February 2013) ,您可以使用与' # '用于提交消息中的注释行。

    你可以使用 #

    Git要求用户在编辑器中编辑消息时给出的各种“提示”行都被注释掉了 #

    这个 core.commentChar 配置变量可用于自定义此'


    理论上,你 核心.commentChar word(多个字符),但git2.0.x/2.1将更加严格(2014年第3季度)。

    看到了吗 commit 50b54fd 通过 Nguyễn Thái Ngọc Duy ( pclouds )

    配置:严格要求core.commentChar

    我们不支持评论 (至少还没有)。多字节字符编码也可能被误解。

    带有两个逗号的测试被更新,因为它违反了这一点。它添加了一个补丁 introduces core.commentChar in eff80a9 为什么?


    git2.0.x/2.1(2014年第3季度)将为 核心.commentChar :
    看到了吗 commit 84c9dc2

    什么时候? 核心.commentChar 是“ auto “,注释字符以” #

    # '作为自定义模板中的注释字符,如果最终注释字符不同,则将其转换。
    它认为自定义模板中的“#”行是提交消息的一部分。所以不要用这个自定义模板。

    “auto”的候选字符列表为:

    # ; @ ! $ % ^ & | :
    

    git commit -m '#1 fixed issue' 将自动将commentChar切换为' ; '因为' '已在提交消息中使用。

        3
  •  96
  •   Slipp D. Thompson Jon Brooks    8 年前

    这里的答案很好,也很详细,但对于像我这样的git noob来说,定制git配置选项并不是那么明显。下面是一个可以改变的例子 # ; 注释字符:

    git config core.commentChar ";"
    

    这就是你需要做的。

        4
  •  64
  •   Olivier Verdier    14 年前

    您可以使用命令行选项 -m :

    git commit -m "#123 fixed"
    
        5
  •  45
  •   Owain Williams    9 年前

    如果您正在执行交互式重新基,那么当您保存提交消息时,其中没有任何内容(因为 # 一开始,它只是一个注释,因此被忽略了)git将告诉您该怎么做:

    Aborting commit due to empty commit message.
    Could not amend commit after successfully picking 5e9159d9ce3a5c3c87a4fb7932fda4e53c7891db... 123 salt hashed passwords
    This is most likely due to an empty commit message, or the pre-commit hook
    failed. If the pre-commit hook failed, you may need to resolve the issue before
    you are able to reword the commit.
    You can amend the commit now, with
    
            git commit --amend
    
    Once you are satisfied with your changes, run
    
            git rebase --continue
    

    所以,只要修改信息:

    git commit --amend -m "#123 salt hashed passwords"
    

    git rebase --continue
    
        6
  •  33
  •   Slipp D. Thompson Jon Brooks    8 年前

    git commit --cleanup=scissors Git v2.0.0 2014.05.21

    git commit --help

    --cleanup=<mode>
      scissors
        Same as whitespace, except that everything from (and including) the line
        "# ------------------------ >8 ------------------------" is truncated if the message
        is to be edited. "#" can be customized with core.commentChar.
    
        7
  •  1
  •   valignatev    8 年前

    #issueNumber 所以我把这个样板放在我的桌子上 vim .git/hooks/commit-msg :

    NAME=$(git branch | grep '*' | sed 's/* //') 
    echo "$NAME"' '$(cat "$1") > "$1"
    

    假设我们有分支 #15 我们做了一个确认消息 add new awesome feature . 使用这种方法,最终的提交消息将 #15 add new awesome feature .

        8
  •  0
  •   wilhelmtell    14 年前

        9
  •  -1
  •   helvete user3408541    3 年前

    用空格字符开始提交消息就足够了 就在 # 烧焦。

    那么 git 停止将行作为注释 github 可以使用散列的票号而没有任何问题。

    vim 的默认语法高亮显示甚至通过将颜色从 评论的 心满意足的

    enter image description here

    推荐文章