Bird
0
0

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📝 Workflow Q15 of 15
Git - Remote Repositories
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?
AGit creates dev branch tracking origin/main instead
BGit errors out because origin/dev does not exist
CGit creates dev branch but does not track any remote
DGit creates dev branch tracking origin/dev anyway
Step-by-Step Solution
Solution:
  1. Step 1: Understand tracking branch creation requirements

    To create a tracking branch, the remote branch must exist. If it doesn't, Git cannot link to it.
  2. Step 2: Predict Git behavior

    Running git checkout --track origin/dev when origin/dev does not exist causes Git to error out.
  3. Final Answer:

    Git errors out because origin/dev does not exist -> Option B
  4. Quick Check:

    Tracking branch requires existing remote branch [OK]
Quick Trick: Remote branch must exist before tracking branch creation [OK]
Common Mistakes:
  • Assuming Git creates tracking branch without remote
  • Thinking Git tracks origin/main by default
  • Ignoring error messages about missing remote branch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes