Lesson 05
Branches
A branch is a movable name for a line of commits. Creating one names a path; it does not switch you to it.
Visual Explanation
Ready to run git branch feature/login.
Keep These Ideas
- Branch Pointer
- A branch names one commit and moves forward when you commit on it.
- Create, Don't Switch
- git branch creates the name. HEAD remains on your current branch.
- No new commit
- Creating a branch adds a name at an existing checkpoint; history does not grow yet.
The Real Command
Terminal
git branch feature/logingit branch feature/login creates a branch pointer at your current commit without switching to it.
Command Details
git branchThe * marks your current branch. It is output from Git, not a character you type.
Example Output
feature/login
* maingit branch --list "feature/*"* is a wildcard here. The quotes keep the pattern together while Git lists matching branch names.
Example Output
feature/logingit branch -d feature/login-d deletes a safely merged branch. Git refuses when the branch contains work that has not been merged.
Knowledge Check
Name a Separate Path
Create and inspect branch names without confusing creation with switching.
Question 1 of 5
- Question 1: current
- Question 2: not started
- Question 3: not started
- Question 4: not started
- Question 5: not started