CodeBlanks Logo Icon CodeBlanks

Creating a branch

Learn to create a new branch with git branch.

Create a New Branch

You can create a branch by writing its name after the git branch command. This operation creates the branch but does not change your current working branch.

git branch development

To switch to the new branch, you can separately use git switch development.

Choose Clear Branch Names

Branch names should describe the feature or fix being worked on. Names such as login-screen or bugfix-menu make the branch purpose clear.

git branch login-screen
git branch bugfix-menu

Creating a branch does not automatically activate it. You need git switch to move to it.

Practice Create Two Separate Work Branches

Create two new branches named mobile-interface and api-test. Then print a message indicating that the operation is complete.

Starter code

terminal
print("Yeni dallar oluşturuluyor")

Sample solution

terminal
git branch mobil-arayuz
git branch api-test
print("İki çalışma dalı oluşturuldu")

Expected output

Yeni dallar oluşturuluyor
İki çalışma dalı oluşturuldu

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which of the following commands correctly creates a branch?

  • git add test-area
  • git branch test-area Correct answer
  • git switch -d test-area
  • git merge test-area

Explanation: Correct. A new branch is created using the name written after the git branch command.

2 Give the Branch a Descriptive Name

Question
git branch ____
Answer
git branch api-gelistirme

Explanation: The api-gelistirme name creates a new branch describing the feature being developed.

3 Branch Creation Terms

Term Meaning
git branch raporlama Creates the reporting branch
Dal adı Identifies the work area
git switch Switches to another branch
Mevcut dal The currently active branch

All lessons in Intermediate

20 Intermediate final

  1. Branch management
  2. Rebase
  3. Conflict
  4. PR flow