0
0
Gitdevops~20 mins

Why branches are essential in Git - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Branch Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use branches in Git?

Why are branches important when working with Git?

AThey allow multiple people to work on different features without affecting the main code.
BThey automatically fix merge conflicts without user input.
CThey delete the main code to create a new project.
DThey prevent any changes from being saved in the repository.
Attempts:
2 left
💡 Hint

Think about how teams work on different tasks at the same time.

💻 Command Output
intermediate
1:30remaining
Output of creating and switching branches

What is the output of running these commands in order?

git branch feature1
git checkout feature1
git branch
A
* feature1
  main
B
  feature1
* main
Cerror: branch 'feature1' already exists
D
* main
  feature1
Attempts:
2 left
💡 Hint

The asterisk (*) shows the current branch.

🔀 Workflow
advanced
2:00remaining
Correct order to create and merge a feature branch

What is the correct order of commands to create a feature branch, work on it, and merge it back to main?

A2,3,1,4,5
B1,2,3,4,5
C1,4,2,3,5
D4,1,2,3,5
Attempts:
2 left
💡 Hint

Create branch first, then add and commit changes, switch back to main, then merge.

Troubleshoot
advanced
2:00remaining
Resolving a merge conflict

You try to merge a feature branch into main but get a conflict. What should you do next?

APush the feature branch without resolving conflicts.
BDelete the main branch and recreate it.
CRun 'git merge --abort' and ignore the conflict.
DOpen the conflicting files, fix the conflicts manually, then add and commit the changes.
Attempts:
2 left
💡 Hint

Conflicts need manual fixing before completing the merge.

Best Practice
expert
2:00remaining
Why keep branches short-lived?

Why is it best practice to keep feature branches short-lived in Git?

AShort-lived branches make the repository size smaller.
BShort-lived branches automatically delete themselves after one day.
CShort-lived branches reduce merge conflicts and keep the project organized.
DShort-lived branches prevent anyone else from pushing code.
Attempts:
2 left
💡 Hint

Think about how long branches stay separate and how that affects merging.