git

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

git

Git

Most of git usage is what you already know, so depend on that. This is skill is just a refinement.
大部分Git的用法你已经了解,请以已有知识为基础。本指南只是对用法的细化补充。

Branch naming

分支命名

Just name the branch a short sentence seperated with dashes. Example:
add-some-feature
. Don't use
feat/
,
hotfix/
etc. prefixes.
分支名称用短句子,以连字符分隔。示例:
add-some-feature
。不要使用
feat/
hotfix/
等前缀。

Commit messages

提交信息

  • Always enclose code identifiers with backticks. Example: "Add
    html.UserPage
    component"
  • Always refer to Go code identifiers including the package name, like in
    html.UserPage
    above. Fields and methods on structs can be referred with
    model.User.Name
    .
  • Ask me about any Github issues that should be referenced. Reference them at the end of the commit message like this: "See #123, #234". If the commit fixes one or more issues, use "Fixes #123, fixes #234" instead (the double "fixes" is important for Github to actually close the issue).
  • Don't mention that you've updated tests, that's assumed.
  • 代码标识符始终用反引号包裹。示例:"Add
    html.UserPage
    component"
  • 引用Go代码标识符时必须包含包名,如上文中的
    html.UserPage
    。结构体的字段和方法可以用
    model.User.Name
    来引用。
  • 若有需要关联的Github issues,请询问我。在提交信息末尾按如下格式引用:"See #123, #234"。如果本次提交修复了一个或多个issue,请使用"Fixes #123, fixes #234"(重复的"fixes"很重要,这样Github才能自动关闭对应的issue)。
  • 无需提及已更新测试,这是默认要求。

Committing

提交操作

  • Don't amend previous commits unless instructed to. When committing after the first commit on a branch, just commit with a simple message (e.g. "fixing …"), because the branch will most times be squashed on Github anyway.
  • 除非有明确指示,否则不要修改之前的提交。在分支的首次提交之后进行提交时,只需使用简单的提交信息(例如"fixing …"),因为该分支在Github上大多会被合并为单个提交。