>_ IzzyLab

Hands-on task

This task is step 6 of the course “Everyday Git”

Branch and merge

medium~12 min

The project project lives in GitLab and is already cloned to /root/project; git push works right away (the web sign-in is on the GitLab tab).

Create a branch feature, add a new file feature.txt in it with a commit, switch back to main and merge feature into it. Then push both branches to GitLab: main with the merged feature.txt, and feature itself — it must stay.

In the GitLab web UI, check that feature.txt has appeared in main and that feature is in the list of branches.

What you'll practise:
  • git
  • branches
  • merge
  • checkout
  • git push
  • GitLab

Topic breakdown

A branch in git is merely a lightweight movable pointer to a commit; creating a branch doesn't copy files, it just starts a new line of history. Working in a separate branch, you record commits only in it — main doesn't know about them until they're "merged" in. A merge moves one branch's commits into another: with a linear history this is usually a fast-forward, and the source branch keeps living as an independent pointer after the merge.

What's checked

  1. feature branch with feature.txt is in GitLab
  2. current branch is main
  3. feature.txt is merged into main in GitLab
  4. feature branch is merged into main

What it looks like