Github help - zhongjiajie/zhongjiajie.github.com GitHub Wiki

github help

github help是github官方针对用户的帮助文档

github写作指南

常用链接

FAQ-写作

  • 代码过时了,会在源代码上面加一条横线,用两个~包裹 Map map = new HashMap();
  • 怎么通过链接跳转到markdown别的标题How to link to a named anchor in Multimarkdown: ## 1.1 Hello World 要转成 [Link](#11-hello-world)
  • 引用github中文件的内容,只节选部分内容.如果是单行#L<line-number>如果是多行#L<from-line-number>-L<to-line-number>

开发者相关

搜索项目

  • path:app/public: 在app/public directory目录下搜索
  • extension:css: 只找 css 文件的代码
  • filename:.vimrc commands: 搜索 文件名匹配.vimrc 并且包含commands的代码
  • in:path: 路径中包含***的代码
  • language:python: python相关项目
  • stars:>300: 项目stars数大于300
  • size:>200000: 项目大小超过 200kb
  • fork:true: 被fork过
  • minitest filename:test_helper path:test language:ruby: 在test目录中搜索包含minitest且文件名匹配"test_helper"的ruby代码

FAQ

review PR

github help-Reviewing proposed changes in a pull request是关于如何对别的pr进行review和discuss的部分.其流程大致是(review目前仅支持单行的review,显示的内容是选中行及选中行的前三行):

  • 找到pull requests
  • 点击Files changed查看别的贡献者进行了什么修改
  • 点击Files changed中的修改行号旁边的蓝色评论按钮,此时有suggestion按钮对pr的代码进行建议
  • 点击了start review之后review会处在Pending状态,此时可以点击Start a new conversation新增一个讨论,或者点击finish your review完成review
    • start review中写的内容会显示在review的里面(后面还有一个对整个review的总结),review的目的是对代码作出修改意见,或者询问作者为什么要增加这些代码不是别的.
  • 在review没有发布(comment)前只对你可见,如果此时不想发布点击cancel review按钮
  • 完成了review之后给出建议后需要submit review
  • 点击Files changed,在改变的代码中点击Review changes
  • 输入comment,总结你对这些意见更改的反馈内容
  • 选择review的类型
    • Commnet: 留下常规的反馈,没有明确的统一或者要求.Select Comment to leave general feedback without explicitly approving the changes or requesting additional changes.
    • Approve: 提交review,并且同一合并pr.Select Approve to submit your feedback and approve merging the changes proposed in the pull request.
    • Request changes: 要完成你的反馈才能将pr合并到分支中.Select Request changes to submit feedback that must be addressed before the pull request can be merged.
  • 点击Submit review

怎么在review中引用多行代码

根据How to select/comment on a range of lines in github pull request得知,目前github暂不支持这个功能

参与问题讨论和pr

将别人的pr拉到自己的分支

github help-Checking out pull requests locally

  • git fetch origin pull/ID/head:BRANCHNAME: 将PR拉取到本地
  • git checkout BRANCHNAME: 切换到本地分支

创建一个draft的PR

如何创建draft-PR: 创建成为draft的PR不能被merge,直到将这个PR的Draft标签去掉

创建Co-authored的提交

如果一个commit涉及到了多个作者,可以使用github的Co-authored-by功能,详见creating-a-commit-with-multiple-authors,即在commit信息中增加合作者名称Co-authored-by: name <[email protected]>,相关的真实案例见AIRFLOW-5749

创建一个draft PR

创建PR的时候不要直接创建,而是使用Create Draft Pull Request,的方式创建,就是一个draft PR,如果PR已完成,可以让大家帮忙查看了,就可以使用changing-the-stage-of-a-pull-request修改PR的状态

Github Action

如何传递一个bash变量

这里以获取日期为例

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Get current date
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

⚠️ **GitHub.com Fallback** ⚠️