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.
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)- A90% (19)
- B5% (1)
- C5% (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.
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.
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.
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.
"--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
Community Discussion
No community discussion yet for this question.