0
0
Gitdevops~20 mins

Creating branches with git branch - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Branch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of creating a new branch?
You run the command git branch feature1 in a repository. What will be the output shown in the terminal?
Git
git branch feature1
ASwitched to branch 'feature1'
BCreated branch feature1 and switched to it.
Cerror: branch 'feature1' already exists.
DNo output is shown; the branch is created silently.
Attempts:
2 left
💡 Hint
The git branch command creates a branch but does not switch to it.
💻 Command Output
intermediate
1:30remaining
What branches exist after creating a branch?
You have a repository with a single branch main. You run git branch dev. What branches will git branch list now?
Git
git branch dev
git branch
A* dev
B
  main
* dev
C
* main
  dev
D dev
Attempts:
2 left
💡 Hint
The star (*) marks the current branch.
🔀 Workflow
advanced
2:00remaining
Which command sequence creates and switches to a new branch?
You want to create a new branch called featureX and start working on it immediately. Which sequence of commands achieves this?
A
git branch featureX
git checkout featureX
Bgit branch featureX
C
git checkout featureX
git branch featureX
Dgit checkout -b featureX
Attempts:
2 left
💡 Hint
Creating a branch and switching are two separate steps unless combined.
Troubleshoot
advanced
1:30remaining
Why does git branch fail to create a branch?
You run git branch main but get the error: fatal: A branch named 'main' already exists. What is the cause?
AThe branch name 'main' is reserved and cannot be used.
BThe branch 'main' already exists; you cannot create it again.
CYou need to add files before creating a branch.
DYou are not inside a git repository.
Attempts:
2 left
💡 Hint
Branch names must be unique in the repository.
🧠 Conceptual
expert
2:30remaining
What happens internally when you run git branch new-feature?
Choose the correct description of what git branch new-feature does internally in the git repository.
AIt creates a new pointer named 'new-feature' that points to the current commit, without changing HEAD.
BIt creates a new commit named 'new-feature' and switches HEAD to it.
CIt deletes the current branch and replaces it with 'new-feature'.
DIt creates a new branch and immediately switches HEAD to it.
Attempts:
2 left
💡 Hint
Think about what a branch really is in git.