Summary - Branch basics
- Git course
- Beginner
- Lesson 56/80
- 5 min
Combine branch and switch to build a branch workflow.
Branch creation and switching workflow
To create a separate line of work in Git, you can first create a branch with git branch. Then use git switch to move to that branch and continue working. You can use git branch at any time to list branches.
git branch new-feature
git switch new-feature
git branchIn this workflow, creating a branch and switching to it are separate steps.
Practice Complete the new branch workflow
Create a new branch named interface. Switch to this branch and finally list the existing branches.
Starter code
# Yeni dalı oluştur
# Yeni dala geç
# Dalları listeleSample solution
git branch arayuz
git switch arayuz
git branchExpected output
main * arayuz
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the correct order to create and switch to a new branch?
- git branch new, then git switch new Correct answer
- git status new, then git log new
- git add new, then git commit new
- git switch new, then git branch new
Explanation: First, <code>git branch</code> creates the branch, then <code>git switch</code> moves to it.
2 Switch to a new working branch
git branch ozellik
git ____ ozellik
git branch ozellik
git switch ozellik
Explanation: After creating the new branch, use <code>git switch ozellik</code> to move to it.
3 Match the branch workflow
| Term | Meaning |
|---|---|
git branch |
Lists existing branches |
git branch test |
Creates test branch |
git switch test |
Switches to test branch |
HEAD |
Identifies current position |