Designing and Implementing Microsoft DevOps Solutions: AZ-400 Exam Answer

Git Commit Parameter for Excluding Work Item Tag

Question

You are using GitHub as a source code repository.

You create a client-side Git hook on the commit-msg event. The hook requires that each commit message contain a custom work item tag.

You need to make a commit that does not have a work item tag.

Which git commit parameter should you use?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B

The commit-msg hook is invoked by git-commit and git-merge, and can be bypassed with the --no-verify option.

https://git-scm.com/docs/githooks

The correct answer is B. --no-verify.

Explanation:

In Git, a hook is a script that Git executes before or after an event such as a commit, push, or receive. The hook can be used to validate the changes, enforce code quality, and prevent mistakes. Git hooks are customizable and can be created by the user.

In this scenario, a client-side Git hook is created on the commit-msg event, which means that the hook will be executed after a commit message is entered but before the commit is finalized. The hook requires that each commit message contain a custom work item tag.

To make a commit that does not have a work item tag, the user needs to bypass the hook. The --no-verify parameter can be used to skip the Git hook validation and commit the changes without triggering the hook. Therefore, option B is the correct answer.

Option A (--squash) is used to combine multiple commits into a single commit. It does not affect the commit message or the Git hook validation.

Option C (--message '') is used to provide a commit message in the command line without opening an editor. However, if the Git hook requires a custom work item tag, an empty message will still trigger the hook.

Option D (--no-post-rewrite) is used to disable the post-rewrite hook, which is executed after a commit is rewritten. It does not affect the commit message or the Git hook validation.