Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a tracking branch in Git?
A tracking branch is a local branch that is linked to a remote branch. It helps you keep your local branch updated with changes from the remote branch.
Click to reveal answer
beginner
How do you create a local branch that tracks a remote branch?
You can create a tracking branch using: git checkout -b local_branch_name origin/remote_branch_name or simply git checkout remote_branch_name if it exists remotely.
Click to reveal answer
intermediate
What command shows the tracking branches and their status?
Use git branch -vv to see local branches, their tracking branches, and if they are ahead or behind.
Click to reveal answer
beginner
Why are tracking branches useful in teamwork?
Tracking branches help you easily fetch and merge changes from teammates by linking your local work to the remote branch they update.
Click to reveal answer
intermediate
How do you change the upstream branch a local branch tracks?
Use git branch --set-upstream-to=origin/branch_name to change the remote branch your local branch tracks.
Click to reveal answer
What does a tracking branch in Git do?
ALinks a local branch to a remote branch to track changes
BDeletes a remote branch automatically
CCreates a backup of your repository
DMerges two unrelated branches
✗ Incorrect
A tracking branch connects your local branch to a remote branch so you can easily fetch and merge updates.
Which command shows local branches with their tracking info?
Agit branch -vv
Bgit status
Cgit fetch
Dgit merge
✗ Incorrect
git branch -vv lists branches with their tracking branches and status.
How do you set a local branch to track a remote branch?
Agit clone branch_name
Bgit push origin branch_name
Cgit branch --set-upstream-to=origin/branch_name
Dgit init
✗ Incorrect
The --set-upstream-to option links your local branch to a remote branch.
What happens when you run git checkout remote_branch_name if the branch exists remotely but not locally?
APushes local changes to remote
BDeletes the remote branch
CShows an error
DCreates a local tracking branch for the remote branch
✗ Incorrect
Git creates a local branch that tracks the remote branch automatically.
Why is it helpful to have tracking branches in a team project?
AThey prevent anyone from pushing changes
BThey simplify syncing your work with teammates' changes
CThey automatically resolve conflicts
DThey delete old branches
✗ Incorrect
Tracking branches make it easy to fetch and merge teammates' updates.
Explain what a tracking branch is and how it helps in managing code with a remote repository.
Think about how your local work stays updated with others' work.
You got /3 concepts.
Describe the steps and commands to create a local branch that tracks a remote branch and how to check its status.
Focus on commands that connect and show tracking info.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of a tracking branch in Git?
easy
A. To delete remote branches automatically
B. To create a backup of the repository
C. To link a local branch to a remote branch for easy syncing
D. To merge two unrelated branches
Solution
Step 1: Understand tracking branch concept
A tracking branch connects your local branch to a remote branch, making syncing easier.
Step 2: Identify the main purpose
This connection allows you to push and pull changes without extra typing.
Final Answer:
To link a local branch to a remote branch for easy syncing -> Option C
Quick Check:
Tracking branch = link local to remote [OK]
Hint: Tracking branches link local and remote branches automatically [OK]
What will the output show about the feature branch?
medium
A. feature branch tracks origin/feature with commit info
B. feature branch does not track any remote branch
C. feature branch is deleted
D. feature branch tracks origin/main
Solution
Step 1: Understand the checkout command
git checkout -b feature origin/feature creates a local branch feature starting at origin/feature and sets it to track that remote branch.
Step 2: Interpret git branch -vv output
This command shows local branches with tracking info and commit details. The feature branch will show it tracks origin/feature.
Final Answer:
feature branch tracks origin/feature with commit info -> Option A
Quick Check:
Checkout -b with remote sets tracking branch [OK]
Hint: Checkout -b with remote branch sets tracking automatically [OK]
Common Mistakes:
Assuming no tracking is set by checkout -b
Thinking branch is deleted after creation
Confusing tracking branch with origin/main
4. You ran git branch --track feature origin/feature but got an error: fatal: A branch named 'feature' already exists. What is the best way to fix this?
medium
A. Delete the existing feature branch first or use checkout to switch
B. Rename the remote branch
C. Run git branch --force feature origin/feature
D. Use git push to update the remote branch
Solution
Step 1: Understand the error message
The error says a local branch named 'feature' already exists, so you cannot create it again.
Step 2: Choose the correct fix
You can either delete the existing branch if not needed or switch to it using git checkout feature. Renaming remote or forcing branch creation is incorrect here.
Final Answer:
Delete the existing feature branch first or use checkout to switch -> Option A
Quick Check:
Existing branch blocks creation; delete or switch [OK]
Hint: Existing branch blocks creation; delete or checkout instead [OK]
Common Mistakes:
Trying to rename remote branch unnecessarily
Using --force incorrectly with git branch
Confusing push with branch creation errors
5. You want to create a local branch dev that tracks origin/dev, but origin/dev does not exist yet. What happens if you run git checkout --track origin/dev?
hard
A. Git creates dev branch tracking origin/main instead
B. Git errors out because origin/dev does not exist
C. Git creates dev branch but does not track any remote
D. Git creates dev branch tracking origin/dev anyway