AZ-400 Question 86
Select 2You are managing a Git-based repository in Azure DevOps for a microservices application. You have just finalized version 2.0 of a service and you want to tag the exact commit for the release so that the entire team can easily identify and reference it. You also want to include a message that describes the new release. Which two actions should you take to correctly configure this tag and make it visible to other contributors?
- A
Create an annotated tag referencing the v2.0 release commit by using the command 'git tag -a v2.0 -m "Release 2.0" <commit_sha>'.
- B
Push the tag to the remote repository using the command 'git push origin v2.0'.
- C
Use Azure DevOps Branch Policies to automatically create and maintain tags for all commits.
- D
Run 'git revert <commit_sha>' and then commit again with 'v2.0' in the message to record the tag.
Show answer and explanation
Correct answers: A, B
Explanation
To organize and identify specific releases in a Git repository, you typically create an annotated tag that points directly to the final commit of a release (e.g., v2.0), including a relevant message. You then push this tag to the remote repository so that the entire team can reference and retrieve it. Microsoft and Git documentation (e.g., docs.microsoft.com/azure/devops/repos/git/git-tags) recommend using annotated tags for production releases because they store additional metadata, such as the tagger� identity and the date.
- A. Correct.
Option 1 is correct. An annotated tag ('-a') allows you to include a message describing the release and references the concluding commit for version 2.0. This makes it easier for the team to see important context at a glance.
- B. Correct.
Option 2 is correct. After creating a local tag, you need to push it to the remote repository using the 'git push origin <tag_name>' command so that everyone else on the team can see it and fetch it.
- C. Incorrect.
Option 3 is incorrect. Azure DevOps Branch Policies do not automatically create tags. Branch Policies are primarily used to enforce requirements such as code reviews, build validation, and status checks before merging.
- D. Incorrect.
Option 4 is incorrect. The 'git revert' command creates a new commit that undoes changes from a specified commit. It does not create a tag or associate a tag with the reverted commit. Adding 'v2.0' to the commit message also does not create a Git tag.