Summary - Branch management
- Git course
- Intermediate
- Lesson 4/82
- 5 min
Combine branch commands to build a branch management flow.
Combine Branch Management Operations
In branch management, you first inspect existing branches, create a new branch when needed, and delete branches that are no longer required after the work is complete. These operations help keep project history organized.
git branch -a
git branch new-module
git branch -d old-moduleBefore deleting a branch, make sure it is not active and that its changes are preserved.
Practice Create, List, and Delete Branches
Create a new branch named performance. List local and remote branches together. Then delete the merged old-interface branch that is no longer needed. Finally, print a message confirming completion.
Starter code
print("Dal yönetimi başlıyor")Sample solution
git branch performans
git branch -a
git branch -d eski-arayuz
print("Dal yönetimi tamamlandı")Expected output
Dal yönetimi başlıyor Dal yönetimi tamamlandı
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which operation can be performed after creating a new branch in a branch management workflow?
- Delete the active branch directly
- Convert the remote branch list into a local file
- Use the branch name as a commit message
- Delete a merged branch that is no longer needed after the work is complete Correct answer
Explanation: Correct. After the work is complete, you can delete merged branches that are no longer needed with the -d option.
2 List Branches During Management
git branch ____
git branch -a
Explanation: The -a option displays local and known remote branches together.
3 Branch Management Workflow
| Term | Meaning |
|---|---|
git branch -a |
Displays branches together |
git branch yeni-modul |
Creates a new work area |
git branch -d eski-modul |
Safely deletes an old branch |
git switch main |
Switches to the main working branch |