Git Branch Creation and Checkout Commands

300-435 By islever Editorial Last updated

Construct a network automation solution with Python using Netmiko to manage and monitor configurations

Short answer

C Use git checkout -b feature to create and switch to the new branch.

Question

An engineer stored source code in a Git repository and is ready to develop a new feature. The production release is stored in the master branch. Which
commands create the new feature in a separate branch called feature and check out the new version?
  1. [sampleXML/xmlfile-12_1.png]
  2. [sampleXML/xmlfile-12_2.png]
  3. [sampleXML/xmlfile-12_3.png] Correct Answer
  4. [sampleXML/xmlfile-12_4.png]

Key Takeaways

The trap is forgetting that simply typing 'git checkout feature' fails if the branch doesn't exist; you must explicitly create it first or use the -b flag.

Learn how to correctly create a new Git branch and switch to it using the git checkout -b command in the 300-435 exam context.

Common mistake: Selecting an option that only creates the branch (e.g., git branch feature) without switching to it, leaving the engineer still on master.

Expert Analysis

The question asks for the Git commands to create a new branch named feature and immediately switch the working directory to that new branch. This is a standard two-step workflow often combined into one command in modern Git versions.

The correct sequence involves creating the branch and checking it out. The command git checkout -b feature performs both actions atomically: it creates a new branch named feature based on the current HEAD (which is master) and checks it out. Alternatively, one could use git branch feature followed by git checkout feature, but single-command options are preferred if available.

Looking at the likely structure of the image-based options:

  • Option C is indicated as correct by community consensus and aligns with standard Git usage for this specific task.
  • A common distractor might be git checkout feature without the -b flag, which would fail if the branch does not exist yet.
  • Another distractor might be git branch feature alone, which creates the branch but leaves the user on master.

Therefore, the decisive action is using git checkout -b feature or an equivalent combination that satisfies both creation and checkout requirements simultaneously.

Official Reference

https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow

This link opens the official vendor documentation in a new tab.

Exam Strategy

When dealing with Git questions in the 300-435 exam, always verify if the operation requires multiple steps. If the question asks to 'create AND check out,' look for the -b flag with checkout or separate branch/checkout commands. Memorize the shorthand syntax as it saves time and reduces error potential during the timed exam.

Frequently Asked Questions

What does the -b flag do in git checkout?

The -b flag tells Git to create a new branch before checking it out, combining two steps into one command.

Can I create a branch without switching to it?

Yes, use 'git branch <name>' to create it, then 'git checkout <name>' to switch later.

More 300-435 FAQ →

Community Votes

C
57%
B
29%
D
14%

57% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 2 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 2

  1. t567 👍 8
    Ans is C https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow
  2. Dominican_Beard 👍 1
    The right answer is C

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All 300-435 Questions

Access 150 questions with complete answers and detailed explanations.

View Full 300-435 Practice Test →

← Back to 300-435 Study Guide