gitpractice.dev

brewly — Ch.5 · Follow the commit convention

Exercise 3 of 6

Before you start

Conventional Commits

Many teams start every summary with a type: feat: for a new feature, fix: for a bug fix, docs:, refactor:, test: or chore: for the rest. An optional scope names the area: fix(cart): round the total.

Tools can then write changelogs and pick version numbers from the history. That only works if each commit holds one kind of change.

The same format is common for pull request titles, because a squash merge turns the title into the commit.

git status
what changed?
git add <file>
stage one change
git commit -m "type: summary"
commit it
git push -u origin <branch>
publish the branch

Pull requests

Teams rarely commit to main directly. You push a branch and open a pull request: a proposal to merge it, where colleagues read the changes and comment before it goes in.

Pull requests are not part of git. They come from the service hosting the repository, such as GitHub or GitLab. Here, open them with the Pull request button above the code.

You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path