nerdexam
CompTIA

XK0-005 · Question #306

A systems administrator installed Git on a new workstation and wants to ensure all Git projects on this machine are initialized with the same username and email address. Which of the following…

The correct answer is A. git config --global user.name = "James Doe" E. git config --global user.email = "[email protected]". To set a global username and email for all Git projects on a workstation, the administrator should use git config --global user.name and git config --global user.email commands.

System Management

Question

A systems administrator installed Git on a new workstation and wants to ensure all Git projects on this machine are initialized with the same username and email address. Which of the following should the administrator use to meet this goal? (Choose two.)

Options

  • Agit config --global user.name = "James Doe"
  • Becho 'email.addr = "[email protected]"' >> .git/.gitconfig
  • Cecho 'username' = "James Doe"' >> .git/.gitconfig
  • Dgit config username = "James Doe"
  • Egit config --global user.email = "[email protected]"
  • Fgit config email.addr = [email protected]"

How the community answered

(21 responses)
  • A
    76% (16)
  • B
    5% (1)
  • C
    14% (3)
  • D
    5% (1)

Why each option

To set a global username and email for all Git projects on a workstation, the administrator should use `git config --global user.name` and `git config --global user.email` commands.

Agit config --global user.name = "James Doe"Correct

The `git config --global user.name = "James Doe"` command sets the user's name globally across all Git repositories on the machine, ensuring that every commit from this workstation will use "James Doe" as the author name unless overridden locally. The `--global` flag writes to the `~/.gitconfig` file.

Becho 'email.addr = "[email protected]"' >> .git/.gitconfig

Directly appending to `.git/.gitconfig` is incorrect because the global configuration file is typically `~/.gitconfig`, not `.git/.gitconfig`, and direct file manipulation is not the standard way to configure Git.

Cecho 'username' = "James Doe"' >> .git/.gitconfig

Directly appending to `.git/.gitconfig` is incorrect for the same reasons as choice B; the global configuration file is `~/.gitconfig` and direct manipulation is not the standard approach.

Dgit config username = "James Doe"

The `git config username = "James Doe"` command is missing the `user.` prefix for the configuration variable and the `--global` flag, so it would not correctly set the global username.

Egit config --global user.email = "[email protected]"Correct

The `git config --global user.email = "[email protected]"` command sets the user's email address globally for all Git repositories on the machine, ensuring that "[email protected]" is used for all commits from this workstation unless a local override exists. The `--global` flag writes to the `~/.gitconfig` file.

Fgit config email.addr = [email protected]"

The `git config email.addr = [email protected]"` command is missing the `user.` prefix for the configuration variable and the `--global` flag, and also has a syntax error with the unclosed quote, so it would not correctly set the global email.

Concept tested: Git global configuration settings

Source: https://git-scm.com/docs/git-config

Topics

#Git configuration#Git commands#Version control#User identity

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice