nerdexam
CompTIA

XK0-004 · Question #447

Some Bash scripts arc being versioned and stored in a Git repository. Which of the following commands should the Linux administrator use to exclude tmp Wes from being added to the repository during an

The correct answer is A. export GIT_IGNORE=,tmp. The standard Git mechanism for permanently excluding file patterns from staging and commits is to add those patterns to a .gitignore file in the repository.

Scripting, Containers and Automation

Question

Some Bash scripts arc being versioned and stored in a Git repository. Which of the following commands should the Linux administrator use to exclude tmp Wes from being added to the repository during any code adds and commits?

Options

  • Aexport GIT_IGNORE=,tmp
  • Balias git=git commit --ignore=, tmp
  • Cecho .gitignore >> * tmp
  • Dgit config -- blacklist = tmp

How the community answered

(21 responses)
  • A
    90% (19)
  • B
    5% (1)
  • C
    5% (1)

Why each option

The standard Git mechanism for permanently excluding file patterns from staging and commits is to add those patterns to a .gitignore file in the repository.

Aexport GIT_IGNORE=,tmpCorrect

Adding a pattern for temporary files to the repository's .gitignore file (the concept represented by choice A) causes Git to permanently ignore matching files during all future git add and commit operations. The .gitignore file applies consistently across all contributors and invocations without requiring any per-command flags. This is Git's built-in, persistent mechanism for keeping unwanted files such as .tmp files out of version control.

Balias git=git commit --ignore=, tmp

Aliasing the git command with a commit flag is not a valid or portable approach to file exclusion, and --ignore is not a recognized option for git commit.

Cecho .gitignore >> * tmp

The echo command as written appends the string ".gitignore" into files matching *.tmp, which is the reverse of the intended operation - the pattern should be written into the .gitignore file, not the other way around.

Dgit config -- blacklist = tmp

"--blacklist" is not a valid git config key or option - Git has no built-in blacklist configuration setting for excluding files from the index or commits.

Concept tested: Excluding file patterns from Git with .gitignore

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

Topics

#.gitignore#Git#version control#file exclusion

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice