AZ-400: Designing and Implementing Microsoft DevOps Solutions

Configuring and Managing Repositories

Configure Git tags to organize the source control repository

Git tags serve as fixed points—or landmarks—in your commit history, helping you mark version releases and other significant milestones. By leveraging tags, you can easily reference builds, rollback to stable states, and integrate seamlessly with CI/CD pipelines in Azure Repos or any Git-based workflow.

The image explains the role of Git tags, showing them as landmarks for important commits, typically used for version releases or highlighting significant changes. It includes a visual with a Git logo and version numbers V01 to V04.

Why use Git tags?

  • Create immutable release points for reproducibility
  • Simplify collaboration by referencing a specific state of the code
  • Automate deployments by targeting a tag in your pipeline

Types of Git tags

Tag TypeDescriptionTypical Use Case
LightweightA simple ref to a commitQuick local markers
AnnotatedA full Git object (message, author, timestamp)Official release versions

Note

Annotated tags include metadata—such as the tagger’s name, date, and a descriptive message—making them ideal for public releases.

Creating tags

# Create a lightweight tag pointing to HEAD
git tag v2.0

# Create an annotated tag with a message
git tag -a v2.1 -m "Release 2.1: Added performance improvements"

Listing all tags

# Display all tags sorted alphabetically
git tag

Pushing tags to remote

# Push a specific tag to origin
git push origin v2.0

# Push all local tags at once
git push origin --tags

Warning

Avoid force-pushing or rewriting existing tags, as this can lead to inconsistencies in collaborators’ repositories.

Checking out a tag

To view or revert to a tagged commit:

git checkout v2.0

This puts your working directory in “detached HEAD” state. To make changes, create a new branch:

git checkout -b hotfix/v2.0-patch

Sorting tags by semantic version

git tag --sort=v:refname

This ensures v1.10 appears after v1.2.

Integrating Git tags with Azure Repos

Tags pushed to Azure Repos can trigger build and release pipelines. For step-by-step guidance, see Git version control in Azure Repos.


Watch Video

Watch video content

Previous
Large repositories with Scalar