Which of the following should the engineer do to prevent the file from being uploaded to the repository?

Application code is stored in Git. Due to security concerns, the DevOps engineer does not want to keep a sensitive configuration file, app . conf, in the repository.

Which of the following should the engineer do to prevent the file from being uploaded to the repository?

A. Run git exclude app. conf.

B. Run git stash app. conf.

C. Add app . conf to . exclude.

D. Add app . conf to . gitignore.

Answer: D

Explanation:

This will prevent the file app.conf from being tracked by Git and uploaded to the repository. The .gitignore file is a special file that contains patterns of files and directories that Git should ignore. Any file that matches a pattern in the .gitignore file will not be staged, committed, or pushed to the remote repository. The .gitignore file should be placed in the root directory of the repository and committed along with the other files.

The other options are incorrect because:

A. Run git exclude app.conf

This is not a valid Git command. There is no such thing as git exclude. The closest thing is git update-index –assume-unchanged, which tells Git to temporarily ignore changes to a file, but it does not prevent the file from being uploaded to the repository.

B. Run git stash app.conf

This will temporarily save the changes to the file app.conf in a stash, which is a hidden storage area for uncommitted changes. However, this does not prevent the file from being tracked by Git or uploaded to the repository. The file will still be part of the working tree and the index, and it will be restored when the stash is popped or applied.

C. Add app.conf to .exclude

This will have no effect, because Git does not recognize a file named .exclude. The only files that Git uses to ignore files are .gitignore, $GIT_DIR/info/exclude, and core.excludesFile.

Git – gitignore Documentation

.gitignore file – ignoring files in Git | Atlassian Git Tutorial

Ignoring files – GitHub Docs

[CompTIA Linux+ Certification Exam Objectives]

Latest XK0-005 Dumps Valid Version with 136 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments