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

CertStreak
Menu

Configure tags to organize the source control repository

A worked example

Put in order

Your team is preparing release 1.1 of an application. Your local main branch is checked out and up to date with origin/main. Your local clone also contains several personal tags that have never been pushed.

Requirements:

  • Create a release branch named release/v1.1 from main.
  • Make and commit one final hardening fix to a configuration file while the release branch is checked out. Do not commit the fix on main.
  • Mark the release with a tag named v1.1. The tag must be a full tag object that stores the message Release version 1.1, and it must point to the commit that contains the hardening fix.
  • Publish only the v1.1 tag. The release manager will publish the release branch later, and the personal tags must stay local.

Which actions should you perform, in order?

Your order

You didn't answer this one.

Correct order
1Run git checkout -b release/v1.1 main.
2Make the hardening change in the configuration file and run git add ..
3Run git commit -m "Apply final hardening fix for release 1.1".
4Run git tag -a v1.1 -m "Release version 1.1".
5Run git push origin v1.1.
Why

The release branch must be checked out before editing because the requirements explicitly constrain where the hardening work is performed. The fix must then be staged and committed before creating the tag, so that the tag marks the corrected version. An annotated tag created with git tag -a and -m stores the required message. Pushing v1.1 by name publishes that tag without publishing the release branch or the personal tags.

  • Step 1: Run git checkout -b release/v1.1 main. Main is initially checked out, and the requirements specify that the release branch must be checked out when the hardening change is made.
  • Step 2: Make the hardening change in the configuration file and run git add .. The release branch must be checked out before editing. This step stages the change that the next step commits.
  • Step 3: Run git commit -m "Apply final hardening fix for release 1.1". Commits the change staged in step 2 to release/v1.1. This creates the commit that the tag must point to.
  • Step 4: Run git tag -a v1.1 -m "Release version 1.1". Without a commit argument, the tag points at the current commit. Creating it after step 3 makes it point at the commit that contains the fix, and -a with -m creates an annotated tag that stores the required message.
  • Step 5: Run git push origin v1.1. The tag must exist before it can be pushed. Pushing it by name publishes only v1.1 and keeps the personal tags local.
  • Not needed: Run git tag v1.1. This creates a lightweight tag, which is only a pointer. It does not store the required message as metadata, so it fails the requirement for a full tag object.
  • Not needed: Run git push origin --tags. This pushes all local tags, so the personal tags would also be published. That breaks the requirement to publish only v1.1.
  • Not needed: Run git push -u origin release/v1.1. The release branch must remain unpublished until the release manager publishes it later, so this action breaks the stated requirement.

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