Bird
Raised Fist0
Gitdevops~20 mins

Deleting tags in Git - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Tag Deletion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Deleting a local Git tag
What is the output of the command when deleting a local tag named v1.0?
Git
git tag -d v1.0
ADeleted branch 'v1.0' (was 9fceb02)
Berror: tag 'v1.0' not found.
CDeleted tag 'v1.0' (was 9fceb02)
Dfatal: not a git repository (or any of the parent directories): .git
Attempts:
2 left
💡 Hint
Deleting a local tag shows confirmation with the tag name and commit hash.
💻 Command Output
intermediate
2:00remaining
Deleting a remote Git tag
What is the output of the command when deleting a remote tag named release from origin?
Git
git push origin --delete release
Aerror: unknown option `--delete tag'
B
To origin
 - [deleted]         release
Cfatal: remote origin not found.
DDeleted tag 'release' locally
Attempts:
2 left
💡 Hint
Deleting a remote tag uses git push origin --delete <tagname> and shows deletion confirmation.
Troubleshoot
advanced
2:00remaining
Why does deleting a remote tag fail?
You run git push origin --delete v2.0 but get the error error: unable to delete 'v2.0': remote ref does not exist. What is the most likely cause?
AThe remote 'origin' is not configured.
BYou do not have permission to delete tags on the remote.
CThe local tag 'v2.0' is missing.
DThe tag 'v2.0' does not exist on the remote repository.
Attempts:
2 left
💡 Hint
Check if the tag exists on the remote before deleting.
Best Practice
advanced
2:00remaining
Recommended workflow to delete a tag both locally and remotely
Which sequence of commands correctly deletes a tag named hotfix both locally and on the remote named origin?
Agit tag -d hotfix && git push origin --delete hotfix
Bgit tag -d hotfix && git push origin :refs/tags/hotfix
Cgit push origin --delete hotfix && git tag -d hotfix
Dgit push origin :refs/tags/hotfix && git tag -d hotfix
Attempts:
2 left
💡 Hint
Delete local tag first, then delete remote tag with --delete option.
🧠 Conceptual
expert
2:00remaining
Understanding the effect of deleting tags on collaborators
After deleting a remote tag v3.0 with git push origin --delete v3.0, what must collaborators do to remove the tag from their local repositories?
ARun <code>git fetch --prune origin</code> to update and remove deleted remote tags locally.
BRun <code>git tag -d v3.0</code> only; no fetch needed.
CRun <code>git pull</code> to automatically delete the tag locally.
DNo action needed; tags are deleted automatically on fetch.
Attempts:
2 left
💡 Hint
Local tags are not deleted automatically; pruning is required.

Practice

(1/5)
1. What command deletes a tag named v1.0 only from your local Git repository?
easy
A. git tag -d v1.0
B. git delete tag v1.0
C. git remove tag v1.0
D. git push origin --delete v1.0

Solution

  1. Step 1: Understand local tag deletion

    To delete a tag locally, Git uses the command git tag -d <tagname>.
  2. Step 2: Identify the correct command for tag 'v1.0'

    Replacing <tagname> with 'v1.0' gives git tag -d v1.0.
  3. Final Answer:

    git tag -d v1.0 -> Option A
  4. Quick Check:

    Local tag deletion = git tag -d [OK]
Hint: Use 'git tag -d' to delete local tags fast [OK]
Common Mistakes:
  • Using 'git delete tag' which is invalid
  • Trying 'git remove tag' which doesn't exist
  • Confusing local deletion with remote deletion commands
2. Which of the following is the correct syntax to delete a remote tag named release-2?
easy
A. git push origin :release-2
B. git tag -d release-2
C. git remove origin release-2
D. git push --delete origin release-2

Solution

  1. Step 1: Understand remote tag deletion syntax

    To delete a tag from the remote repository, use git push --delete origin <tagname>.
  2. Step 2: Apply to tag 'release-2'

    Replacing <tagname> with 'release-2' gives git push --delete origin release-2.
  3. Final Answer:

    git push --delete origin release-2 -> Option D
  4. Quick Check:

    Remote tag deletion = git push --delete origin [OK]
Hint: Use 'git push --delete origin <tag>' for remote tag removal [OK]
Common Mistakes:
  • Using 'git tag -d' which deletes only local tags
  • Trying 'git remove' which is not a git command
  • Using old syntax like 'git push origin :refs/tags/tagname' without understanding
3. What will be the output after running these commands?
git tag -d test-tag
git push --delete origin test-tag

Assuming test-tag exists locally and remotely.
medium
A. Deletes 'test-tag' locally and remotely successfully
B. Deletes 'test-tag' locally but fails to delete remotely
C. Fails to delete 'test-tag' locally but deletes remotely
D. No deletion happens; commands are incorrect

Solution

  1. Step 1: Delete local tag 'test-tag'

    The command git tag -d test-tag deletes the tag locally if it exists.
  2. Step 2: Delete remote tag 'test-tag'

    The command git push --delete origin test-tag deletes the tag from the remote repository.
  3. Final Answer:

    Deletes 'test-tag' locally and remotely successfully -> Option A
  4. Quick Check:

    Local and remote tag deletion = success [OK]
Hint: Local then remote deletion commands remove tags fully [OK]
Common Mistakes:
  • Assuming local deletion deletes remote tags too
  • Using wrong push syntax for remote deletion
  • Not having permissions to delete remote tags
4. You ran git push --delete origin v2.0 but the remote tag v2.0 still exists. What is the most likely cause?
medium
A. The tag name is case-insensitive and you used wrong case
B. You forgot to delete the local tag first
C. You do not have permission to delete tags on the remote
D. The remote repository does not support tag deletion

Solution

  1. Step 1: Understand remote tag deletion requirements

    Deleting a remote tag requires proper permissions on the remote repository.
  2. Step 2: Analyze why tag still exists remotely

    If the tag still exists after the delete command, lack of permission is a common cause.
  3. Final Answer:

    You do not have permission to delete tags on the remote -> Option C
  4. Quick Check:

    Remote deletion failure often = permission issue [OK]
Hint: Check remote permissions if tag deletion fails [OK]
Common Mistakes:
  • Assuming local tag must be deleted first for remote deletion
  • Ignoring case sensitivity which is usually exact
  • Believing remote always supports tag deletion
5. You want to delete multiple tags named alpha, beta, and gamma both locally and remotely in one go. Which command sequence is correct?
hard
A. git tag -d alpha beta gamma && git push origin alpha beta gamma
B. git tag -d alpha beta gamma && git push --delete origin alpha beta gamma
C. git tag -d alpha beta gamma && git push origin :refs/tags/alpha beta gamma
D. git tag -d alpha beta gamma && git push origin --delete alpha beta gamma

Solution

  1. Step 1: Delete multiple local tags

    The command git tag -d alpha beta gamma deletes all three tags locally in one command.
  2. Step 2: Delete multiple remote tags

    The correct syntax to delete multiple remote tags is git push --delete origin alpha beta gamma.
  3. Final Answer:

    git tag -d alpha beta gamma && git push --delete origin alpha beta gamma -> Option B
  4. Quick Check:

    Multiple tag deletion local + remote = git tag -d + git push --delete origin [OK]
Hint: Use 'git tag -d' then 'git push --delete origin' for multiple tags [OK]
Common Mistakes:
  • Placing '--delete' after 'origin' incorrectly
  • Trying to delete remote tags without '--delete' flag
  • Deleting tags one by one instead of batching