Creating and Publishing Tag v3.0.5 with git tag and git push origin v3.0.5

AZ-400 By islever Editorial Last updated

Configure and manage repositories

Short answer

BC Git tag v3.0.5 creates the tag locally and git push origin v3.0.5 publishes that ref to the remote; a commit message or git add creates no tag at all.

Question

You have a GitHub repository. You need to create a tag named v3.0.5 and ensure that the tag is available in the remote repository. Which two commands should you run? Each correct answer presents part of the solution. NOTE: Each correct selection is worth one point.
  1. git push -force
  2. git push origin v3.0.5 Correct Answer
  3. git tag v3.0.5 Correct Answer
  4. git commit -m ‘tag v3.0.5’
  5. git add ‘tag v3.0.5’

Key Takeaways

git tag creates the tag in the local repository only, and git push origin v3.0.5 transfers that specific ref to the remote, so the tag becomes visible remotely only after the push.

A tag named v3.0.5 must be created in a GitHub repository and made available in the remote repository. A tag only exists locally after it is created, so a second step is required to publish it so the remote repository contains it.

Common mistake: Using git push -force, which overwrites remote history and is both unnecessary and risky here, since a newly created tag does not conflict with anything and simply needs to be pushed.

Expert Analysis

Why the Answer Is Correct

Two distinct actions are needed because a Git tag lives in two places. The first is creating the tag at the current commit locally, which is what git tag v3.0.5 does, naming it so it can be referenced. The second is transferring that ref to the remote repository, which is what git push origin v3.0.5 does with the explicit tag name as the refspec. Only after the push does the tag exist in the remote repository and become available to other clones. The vote was unanimous at 100 for B and C, and UrbanRellik stated the pair concisely as the two commands to run in order.

Why the Other Options Are Wrong

The command git commit -m 'tag v3.0.5' (D) creates a commit whose message happens to contain the text tag v3.0.5, which is not a tag at all. The string lives in the commit log and has none of the ref semantics a tag requires, so it neither creates v3.0.5 nor publishes anything. The command git add 'tag v3.0.5' (E) stages a file whose name is tag v3.0.5, which stages a file path rather than a ref, so it accomplishes nothing toward creating a tag unless such a file exists, in which case it merely stages it. Using git push -force (A) forces the remote ref to be overwritten, which is a destructive operation intended for rewriting history. A newly created tag conflicts with nothing, so forcing is unnecessary and introduces a risk of discarding remote state.

Community Comment Notes

The community was unanimous at 100 for B and C, and the single substance comment from UrbanRellik gave the answer as the two commands in execution order, which is exactly the right level of detail for a two-command question. The absence of further debate reflects that the question has no genuine ambiguity: creating a tag locally and then pushing it are separable operations and both are required, so the two selections are complementary halves of one solution rather than competing answers.

Community Votes

BC
100%

100% of anonymous learners picked answer BC. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 3 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 3

  1. UrbanRellik 👍 1
    git tag v.3.0.5 git push origin v.3.0.5
  2. Bakare118 👍 1
    Confirmed
  3. Mattt 👍 1
    Correct

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Practice All AZ-400 Questions

Access 100 questions with complete answers and detailed explanations.

View Full AZ-400 Practice Test →

← Back to AZ-400 Study Guide