Course progress0%
Course content
45 min

One Task, One Short Branch

Protect main while working on one clearly named change

By the end of this lesson

  • Explain why a team uses branches
  • Create and publish a branch with a clear name

Start from one task

The team writes a small issue:

Title: Add a contact link

The navigation must include a Contact link.
The link must open the contact section.

An issue describes work to discuss and complete. It is not a branch and it does not change the code.

Why create a branch?

main represents the shared, accepted version. Yassine needs a safe place for unfinished work.

main: A -- B
           \
feature/add-contact-link: C -- D

The branch points to Yassine's work without changing main yet.

Start from an updated main:

git switch main
git pull
git switch -c feature/add-contact-link

switch -c creates the branch and moves to it. Confirm the current branch:

git status

Name the intention

Use a short category and description:

Prefix Purpose Example
feature/ Add behavior feature/add-search
fix/ Correct a problem fix/loading-message
docs/ Change documentation docs/setup-guide
refactor/ Reorganize without changing behavior refactor/resource-view
test/ Add or correct tests test/search-filter
chore/ Maintenance work chore/update-dependencies

These names are team conventions, not Git commands. The team should agree on them and use them consistently.

Avoid names such as my-branch, new, work or final. They do not explain the task.

Work and publish the branch

git add index.html
git commit -m "Add contact link to navigation"
git push -u origin feature/add-contact-link

The branch now exists locally and on GitHub. main still does not contain the change.

Before opening the Pull Request

The branch should solve the issue named in its description, contain only that task and have a clear history. git status confirms the current branch, while local verification confirms that the proposed behavior works.

What to remember

Begin with one clear task, update main, then create one short branch. The branch name communicates the kind and purpose of the work.

Lesson complete?

Your progress is saved on this device.