Skip to content

Git naming conventions and best practices

Bhaskar Singh edited this page Mar 29, 2020 · 4 revisions

Branch Naming

Branches created should be named using the following format:

{story type}-{2-3 word summary}

story-type - Indicates the context of the branch and should be one of:

  • ft == Feature
  • bg == Bug
  • ch == Chore
  • rf == Refactor

story-summary - Short 2-3 words summary about what the branch contains

Example

ft-resources-rest-endpoints

PR Naming

The PR title should be named using the following format:

# Story description

Example

# Build out REST Endpoints for Resources (CRUD)

PR Description Template (Markdown)

The description of the PR should contain the following headings and corresponding content in Markdown format.

#### What does this PR do?
#### Description of Task to be completed?
#### How should this be manually tested?
#### Any background context you want to provide?
#### Screenshots (if appropriate)

Commits

Atomic commits should be made with the format:

<type>: <subject>``<BLANK LINE> <body> <BLANK LINE> <footer>

Any line cannot be longer than 100 characters, meaning be concise.

<type> should be:

  • feat: a new feature
  • fix: a bug fix
  • docs: changes to documentation
  • style: formatting, missing semicolons, etc; no code change
  • refactor: refactoring production code
  • test: adding tests, refactoring test; no production code change
  • chore: updating build tasks, package manager configs, etc; no production code change

<subject> text should:

  • use present tense: "save" not "saved" or "saving"
  • not capitalize first letter i.e no "Carry to safety"
  • not end with a dot (.)

Message body (optional) If a body is to be written, it should:

  • written in present tense.
  • include the reason for change and difference in the previous behaviour

Message Footer This should be used for referencing the issues using the following keywords: Start, Delivers, Fixes and Finishes. it should be inside a square bracket. Example:

[Start #345]

or in a case of multiple issues:

[Finishes #5438233, #5891837, #4988398]

Example

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

Reference Link: Git naming conventions