0
0
Gitdevops~20 mins

Working in multiple branches simultaneously in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Multi-Branch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Switching branches with uncommitted changes

You have uncommitted changes in your current branch. What happens if you run git checkout feature-branch?

AGit refuses to switch branches and shows an error about uncommitted changes.
BGit switches to 'feature-branch' and keeps your uncommitted changes.
CGit automatically commits your changes before switching branches.
DGit deletes your uncommitted changes and switches to 'feature-branch'.
Attempts:
2 left
💡 Hint

Think about how Git protects your work when switching branches.

🔀 Workflow
intermediate
2:00remaining
Working on two branches simultaneously

You want to work on two branches at the same time without losing your current work. Which Git feature allows you to save your changes temporarily and switch branches?

Agit reset
Bgit stash
Cgit merge
Dgit clone
Attempts:
2 left
💡 Hint

It saves your changes away temporarily so you can come back to them later.

Configuration
advanced
2:00remaining
Creating a new branch and switching to it in one command

Which command creates a new branch named hotfix and switches to it immediately?

Agit branch hotfix && git checkout hotfix
Bgit create hotfix && git switch hotfix
Cgit switch hotfix
Dgit checkout -b hotfix
Attempts:
2 left
💡 Hint

Look for a single command that does both actions.

Troubleshoot
advanced
2:00remaining
Resolving conflicts when switching branches

You try to switch branches but get a conflict error because of uncommitted changes. What is the best way to resolve this so you can switch branches safely?

ACommit or stash your changes before switching branches.
BForce switch branches with <code>git checkout -f</code> to discard changes.
CRun <code>git merge</code> to combine branches before switching.
DDelete your working directory and clone the repo again.
Attempts:
2 left
💡 Hint

Think about preserving your work safely.

Best Practice
expert
3:00remaining
Managing multiple feature branches efficiently

You have multiple feature branches and want to keep them updated with the main branch changes. Which workflow is best to avoid complex conflicts?

AAvoid updating feature branches until all features are complete.
BMerge the main branch into each feature branch only once at the end.
CRegularly rebase each feature branch onto the latest main branch.
DDelete feature branches and recreate them from main when needed.
Attempts:
2 left
💡 Hint

Think about keeping your work current and conflicts small.