XK0-006 practice question 1 of 15

A DevOps engineer needs to create a local Git repository. Which of the following commands should the engineer use?

Full set: 149 questions
Answer options
A: git init Correct answer
B: git clone
C: git config
D: git add
Correct Answer:
A. git init
Explanation

The git init command is used to create a new, empty Git repository in the current directory. It can also be used to convert an existing, unversioned project into a Git repository. This command creates a .git subdirectory in the project root, which contains all of the necessary metadata and object database for the new repository. This is the fundamental first step for creating a local version control system for a project from scratch.

Why Incorrect

B. git clone is used to obtain a copy of an existing remote repository, not to create a new local one from scratch.
C. git config sets user-specific or global configuration options for Git, but it does not create a repository.
D. git add stages changes for the next commit and operates within an already existing Git repository.

References

1. Official Git Documentation. git-init(1) Manual Page. Retrieved from git-scm.com. It states, "This command creates an empty Git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files."

2. Chacon, S., & Straub, B. (2014). Pro Git (2nd ed.). Apress. Chapter 2.1, "Getting a Git Repository," states: "You can get a Git repository in one of two ways... The first is to take a local directory that is currently not under version control, and turn it into a Git repository... by running the command git init."

3. Loeliger, J., & McCullough, M. (2012). Version Control with Git (2nd ed.). O'Reilly Media. Chapter 3, "Getting Started with Git," details the use of git init as the primary method for creating a new repository.

Scroll to Top