0
0
Gitdevops~10 mins

Creating branches with git branch - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating branches with git branch
Start in main branch
Run 'git branch <new-branch>'
New branch created locally
Check branches with 'git branch'
New branch listed, current branch unchanged
This flow shows how creating a new branch with 'git branch' adds it locally without switching to it.
Execution Sample
Git
git branch feature1
git branch
Creates a new branch named 'feature1' and lists all branches.
Process Table
StepCommandActionResultCurrent Branch
1git branch feature1Create new branch 'feature1'Branch 'feature1' created locallymain
2git branchList all branches* main feature1main
💡 No branch switch occurs; current branch remains 'main'.
Status Tracker
VariableStartAfter Step 1After Step 2
Branchesmainmain, feature1main, feature1
Current Branchmainmainmain
Key Moments - 2 Insights
Does 'git branch <name>' switch to the new branch?
No, it only creates the branch locally. The current branch stays the same as shown in the execution_table step 1 and 2.
How can I see the new branch after creating it?
Use 'git branch' to list all branches. The new branch will appear but is not checked out yet, as shown in execution_table step 2.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the current branch after running 'git branch feature1'?
Amain
Bfeature1
CNo branch
DDetached HEAD
💡 Hint
Check the 'Current Branch' column in execution_table row 1.
At which step does the new branch 'feature1' appear in the branch list?
AStep 1
BBefore Step 1
CStep 2
DIt never appears
💡 Hint
Look at the 'Result' column in execution_table for branch listing.
If you want to switch to the new branch immediately after creating it, what should you do?
ARun 'git branch feature1' again
BRun 'git checkout feature1'
CRun 'git branch -d feature1'
DRun 'git merge feature1'
💡 Hint
Creating a branch does not switch to it; checkout is needed to switch branches.
Concept Snapshot
git branch <name> creates a new branch locally without switching.
Use 'git branch' to list all branches.
Current branch remains unchanged after creation.
To switch, use 'git checkout <name>' or 'git switch <name>'.
Full Transcript
Creating a branch with 'git branch <name>' adds a new branch locally but does not change your current branch. After running the command, you can list all branches with 'git branch' and see the new branch listed. However, you remain on the original branch until you explicitly switch using 'git checkout' or 'git switch'. This helps you prepare branches without moving away from your current work.