Bird
0
0

You cloned a repo and want to track a remote branch feature-x without switching branches. Which command is correct?

hard📝 Application Q9 of 15
Git - Remote Repositories
You cloned a repo and want to track a remote branch feature-x without switching branches. Which command is correct?
Agit fetch origin feature-x
Bgit branch --track feature-x origin/feature-x
Cgit branch feature-x
Dgit checkout feature-x origin/feature-x
Step-by-Step Solution
Solution:
  1. Step 1: Create tracking branch without checkout

    git branch --track feature-x origin/feature-x creates a local branch tracking remote without switching.
  2. Step 2: Analyze other options

    git checkout feature-x origin/feature-x is invalid syntax; git branch feature-x creates branch from current HEAD but does not set tracking; git fetch only downloads data.
  3. Final Answer:

    git branch --track feature-x origin/feature-x -> Option B
  4. Quick Check:

    Create tracking branch without checkout = git branch --track [OK]
Quick Trick: Use 'git branch --track' to create tracking branch without switching [OK]
Common Mistakes:
  • Using checkout with two branch names
  • Assuming git branch sets tracking without --track
  • Confusing fetch with branch creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes