Working with Git

Conventional Commits
Branch Model Naming
Working in feature branch & PR

Conventional Commits

Use a specs for write

standardized and useful commits

Most used commit messages

Please, don't.

e5f4b49 Changes

Where?

e5f4b49 Add vin and plate fields

Why?

e5f4b49 feat(funnel): Add vin and plate fields

Need to go to external tool!

e5f4b49 feat(funnel): Add vin and plate fields

Issue INTCARMTCH-1810 | Pull Request #873

Everything is here

e5f4b49 feat(funnel): Add vin and plate fields

Send vin and plate field from the last funnel step
to accelerate the inspection process and car validation

Issue INTCARMTCH-1810 | Pull Request #873

<type>[(optional scope)]: <description>
[blank line]

[optional body]

[blank line]

[optional footer]

Commit structure

Commits MUST be prefixed with a type, which consists of a verb, followed by a colon and a space.

1 - Type

fix, feat, docs, style, refactor, perf, test, chore

BREAKING CHANGE

An optional scope MAY be provided after a type.
A scope is a phrase describing a section of the codebase enclosed in parenthesis

2 - Scope (optional)

fix (parser), feat(contact), refactor(admin footer)

A description MUST immediately follow

the type/scope prefix.

3 - Description

docs(salesforce): Update Salesforce doc to version 1.1

HINTS!

Capitalize the subject line

Do not end the subject line with a period

Use the imperative mood in the subject line

Limit the subject line to 50 characters

A longer commit body MAY be provided
after the short description.

The body MUST begin one blank line
after the description.

4 - Body

HINTS!

Wrap the body at 72 characters

Use the body to explain what and why vs. how

A footer MAY be provided one blank line
after the body.
The footer SHOULD contain additional
meta-information about the pull-request

5 - Footer

  • Automatically generating CHANGELOGs.
     
  • Automatically determining a semantic version bump.
     
  • Communicating the nature of changes.
     
  • Triggering build and publish processes.
     
  • Making it easier for people to contribute to your projects.

Why Use Conventional Commits

$ npm install -g commitizen

$ npm install -g cz-conventional-changelog

$ echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

Remember it's hard and
we make mistakes

Community to the rescue

$ npm install -g conventional-changelog-cli

$ conventional-changelog -p angular -i CHANGELOG.md -s

Community to the rescue (again)

Generate automagically
CHANGELOGs file

Focus on atomic commits

  • Commit each fix or task as a separate change

  • Only commit when a block of work is complete

  • Commit each layout change separately

  • Joint commit for layout file, code behind file, and additional resources

Atomic Approach

Focusing on atomic commits

  • Easy to roll back without affecting other changes

  • Easy to make other changes on the fly

  • Easy to merge features to other 

Benefits

Branch Model Naming

Keep it simple

Alternatives

$ git checkout {developer-name-initials}/{issue-number}
$ git checkout dp/2076
$ git checkout dp/edit-username
$ git checkout fix/2098
$ git checkout dp/feat/2531
$ git checkout dp/add-email-support-for-seller/1973

Working with
feature branch & PR

A clear commit history it's important

Accurate description and links

Using conventional commits will be totally free

Use labels

&

Tag reviewers

Will be incredibly useful for faster iterations

One pull request = One commit

Atomic commits will help you

Help your reviewers

Before...

$ git rebase -i HEAD~6

pick 0459699 Added cache layer for comments.
pick b7055f8 Fixed variable typo
pick 3767ea4 test online again!!
pick a6fad5f Refactoring
pick 5c0c280 test if works online?
pick 2f22010 changes

# Rebase 78d14b7..ea8fec9 onto 78d14b7 (6 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# ...

During...

$ git rebase -i HEAD~6

r 0459699 Added cache layer for comments.
f b7055f8 Fixed variable typo
d 3767ea4 test online again!!
f a6fad5f Refactoring
d 5c0c280 test if works online?
f 2f22010 changes

# Rebase 78d14b7..ea8fec9 onto 78d14b7 (6 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# ...

You'll love rebase interactive

$ git log -n 1 --oneline

0459699 (HEAD -> master) fix(articles): Move logic from runtime to cache for calculate comments number

After...

Final tips

Use git aliases