首页 文章

在提交消息中链接到GitHub上的问题编号

提问于
浏览
658

是否有可能 automaticallygit commit 消息中有一个指向GitHub问题编号的链接?

8 回答

  • 1

    如果要链接到GitHub问题并关闭问题,可以在Git提交消息中提供以下行:

    Closes #1.
    Closes GH-1.
    Closes gh-1.
    

    (这三个中的任何一个都可以工作 . )请注意,这将链接到该问题并关闭它 . 您可以在blog post中找到更多信息(大约1:40开始观看嵌入式视频) .

    我不确定类似的语法是否会在没有关闭的情况下直接链接到问题 .

  • 161

    他们在他们的博客上写了一篇关于新问题2.0的好文章https://github.com/blog/831-issues-2-0-the-next-generation

    同义词包括

    • 修复了#xxx

    • 已修复#xxx

    • 修复#xxx

    • 关闭#xxx

    • 关闭#xxx

    • 已关闭#xxx

    使用提交消息中的任何关键字将使您的提交被提及或关闭问题 .

  • 53

    如果github包含#issuenbr(偶然发现),则会添加对提交的引用 .

  • 4

    我作为程序员的第一个项目之一就是一个名为stagecoach的gem,它(除其他外)允许自动为分支上的每个提交消息添加一个github问题号,这是一个尚未真正回答的问题的一部分 .

    基本上,在创建分支时,您将使用自定义命令(类似于 stagecoach -b <branch_name> -g <issue_number> ),然后将问题编号分配给yml文件中的该分支 . 然后有一个commit hook自动将问题编号附加到提交消息 .

    我不推荐它用于 生产环境 用途,因为当时我只编程了几个月而且我不再维护它,但它可能对某些人感兴趣 .

  • 61

    Just include #xxx in your commit message to reference an issue without closing it.

    使用新的GitHub issues 2.0,您可以将这些同义词用于reference an issue and close it(在您的提交消息中):

    • fix #xxx

    • fixes #xxx

    • fixed #xxx

    • close #xxx

    • closes #xxx

    • closed #xxx

    • resolve #xxx

    • resolves #xxx

    • resolved #xxx

    您也可以用 gh-xxx 替换 #xxx .

    引用和closing issues across repos也有效:

    fixes user/repo#xxx
    

    在其“帮助”部分中查看the documentation .

  • 3

    您还可以交叉引用回购:

    githubuser/repository#xxx
    

    xxx是问题编号

  • 11

    为了将问题编号链接到您的提交消息,您应该在您的git commit消息中添加: #issue_number .

    Example Commit Message from Udacity Git Commit Message Style Guide

    feat: Summarize changes in around 50 characters or less
    
    More detailed explanatory text, if necessary. Wrap it to about 72
    characters or so. In some contexts, the first line is treated as the
    subject of the commit and the rest of the text as the body. The
    blank line separating the summary from the body is critical (unless
    you omit the body entirely); various tools like `log`, `shortlog`
    and `rebase` can get confused if you run the two together.
    
    Explain the problem that this commit is solving. Focus on why you
    are making this change as opposed to how (the code explains that).
    Are there side effects or other unintuitive consequenses of this
    change? Here's the place to explain them.
    
    Further paragraphs come after blank lines.
    
     - Bullet points are okay, too
    
     - Typically a hyphen or asterisk is used for the bullet, preceded
       by a single space, with blank lines in between, but conventions
       vary here
    
    If you use an issue tracker, put references to them at the bottom,
    like this:
    
    Resolves: #123
    See also: #456, #789
    

    您还可以引用存储库:

    githubuser/repository#issue_number
    
  • 829

    正如对其他答案的补充:如果您甚至不想编写带有问题编号的提交消息并碰巧使用 Eclipse 进行开发,那么您可以安装eGit和Mylyn插件以及Mylyn的GitHub连接器 . 然后,Eclipse可以自动跟踪您正在处理的问题和 automatically fill the commit message ,包括所有其他答案中显示的问题编号 .

    有关该设置的更多详细信息,请参阅http://wiki.eclipse.org/EGit/GitHub/UserGuide

相关问题