0
0
Gitdevops~20 mins

Tracking branches concept in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tracking Branch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is a tracking branch in Git?

In Git, what does a tracking branch do?

AIt is a branch that stores all the commit history of the repository without any connection to remotes.
BIt is a branch that only exists on the remote repository and cannot be checked out locally.
CIt is a temporary branch created during a merge conflict resolution.
DIt is a local branch that automatically syncs with a remote branch, making it easier to pull and push changes.
Attempts:
2 left
💡 Hint

Think about how Git helps you keep your local work updated with changes from others.

💻 Command Output
intermediate
2:00remaining
Output of 'git branch -vv' showing tracking branches

What is the output of the command git branch -vv when you have a local branch feature tracking origin/feature with one commit ahead?

Git
git branch -vv
A* feature 123abc4 [origin/feature] Added new feature
B* feature 123abc4 Added new feature
C* feature 123abc4 [origin/feature: ahead 1] Added new feature
D* feature 123abc4 [origin/feature: behind 1] Added new feature
Attempts:
2 left
💡 Hint

Look for the branch name, commit hash, tracking info, and commit message.

🔀 Workflow
advanced
2:00remaining
Setting up a tracking branch for a new remote branch

You cloned a repository and want to start working on a new remote branch bugfix that was just created. Which command correctly sets up a local tracking branch bugfix to track origin/bugfix?

Agit checkout -b bugfix origin/bugfix
Bgit branch bugfix
Cgit checkout bugfix
Dgit fetch origin bugfix
Attempts:
2 left
💡 Hint

Think about how to create a local branch that tracks a remote branch in one step.

Troubleshoot
advanced
2:00remaining
Why does 'git pull' fail on a tracking branch?

You are on a local branch develop tracking origin/develop. Running git pull gives the error: There is no tracking information for the current branch. What is the most likely cause?

AThe local branch <code>develop</code> is not actually set to track <code>origin/develop</code>.
BThe remote repository <code>origin</code> is unreachable due to network issues.
CYou have uncommitted changes that prevent pulling.
DThe <code>git pull</code> command is deprecated and should be replaced with <code>git fetch</code>.
Attempts:
2 left
💡 Hint

Check if the branch has a remote branch linked.

Best Practice
expert
3:00remaining
Best practice for renaming a tracking branch

You want to rename your local tracking branch feature-old to feature-new while keeping the tracking relationship with origin/feature-old. Which sequence of commands achieves this correctly?

Agit branch -m feature-old feature-new && git push origin feature-new && git branch --set-upstream-to=origin/feature-new feature-new
Bgit branch -m feature-old feature-new && git branch --unset-upstream feature-new && git branch -u origin/feature-old feature-new
Cgit checkout feature-old && git branch -m feature-new && git push origin feature-new
Dgit branch -m feature-old feature-new && git push origin :feature-old feature-new
Attempts:
2 left
💡 Hint

Think about renaming locally and then updating the tracking info without pushing changes to remote branches.