Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

A worked example

Put in order

You have an existing local clone of a GitHub repository, with its complete commit history available. The remote origin points to that repository.

An approved hotfix has the unique commit subject Correct invoice rounding. You have not identified its commit ID. The current HEAD is a later, unapproved commit.

You must publish a lightweight tag named v1.4.1 for the approved hotfix. That tag does not exist locally or on GitHub. Several unrelated tags exist only locally and must remain unpublished.

Which actions should you perform, and in what order?

Your order

You didn't answer this one.

Correct order
1Find the commit with the subject Correct invoice rounding in the local repository history and copy its commit ID.
2Run git tag v1.4.1 <commit-id>, replacing <commit-id> with the copied commit ID.
3Run git push origin v1.4.1.
Why

First identify the approved historical commit so that the tag points to the required hotfix. Create the local tag with that commit ID, then push the named tag to GitHub. Pushing all tags would also publish tags that the scenario requires you to keep local.

  • Step 1: Find the commit with the subject Correct invoice rounding in the local repository history and copy its commit ID. The target commit ID is unknown. Identifying it supplies the explicit target needed to tag the approved hotfix instead of the later HEAD commit.
  • Step 2: Run git tag v1.4.1 <commit-id>, replacing <commit-id> with the copied commit ID. This creates the lightweight tag against the identified hotfix commit. It requires the commit ID obtained from the history.
  • Step 3: Run git push origin v1.4.1. The local tag must exist before it can be pushed. Naming this tag explicitly publishes it without publishing the unrelated local tags.
  • Not needed: Run git push origin --tags. This pushes all local tags, violating the requirement that the unrelated local tags remain unpublished.

Related topics

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free