nerdexam
CompTIACompTIA

XK0-005 · Question #1233

XK0-005 Question #1233: Real Exam Question with Answer & Explanation

The correct answer is C: echo .tmp >> .gitignore. To prevent Git from tracking specific local files like temporary files, add their patterns to the .gitignore file.

Scripting, Containers, and Automation

Question

A Linux administrator needs to add some files in a directory to the Git repository but must exclude some local .tmp files that are occasionally created by the scripts. Which of the following is the BEST way to accomplish this task?

Options

  • Agit rm .tmp
  • Bgit add -x .tmp *
  • Cecho .tmp >> .gitignore
  • Drm -rf .tmp

Explanation

To prevent Git from tracking specific local files like temporary files, add their patterns to the .gitignore file.

Common mistakes.

  • A. git rm .tmp would remove the file .tmp from the Git repository if it was already tracked, but it does not prevent future untracked .tmp files from being listed by Git.
  • B. git add -x .tmp * uses an invalid flag -x for git add; git add is used to stage files for commit, not to exclude them.
  • D. rm -rf .tmp deletes the .tmp file from the filesystem but does not configure Git to ignore similar files in the future.

Concept tested. Git file exclusion (.gitignore)

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

Topics

#Git#Version Control#.gitignore#File Exclusion

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions