Git-> How to Delete a Local Git Tag and Fetch the Latest Version

Tony Mucci
Code Kings
Published in
2 min readAug 10, 2024

How to Delete a Local Git Tag and Fetch the Latest Version

This is handy if your local tag won't update its changes when you try to reset the tag to the most current changes from your repo.

Managing Git tags is a part of any project that uses version control. Sometimes, you might need to delete a tag locally and then fetch the latest version from the remote repository. Here’s a quick guide on how to do just that.

Step 1: Delete the Local Tag

First off, you need to remove the tag from your local repository. This can be done with the following command:

git tag -d <tag-name>

Replace `<tag-name>` with the tag you want to delete. For example, if the tag is `v1.0.0`, the command would look like this:

git tag -d v1.0.0

This deletes the tag locally but doesn’t affect the tag on the remote repository.

Step 2: Fetch the Updated Tags

After removing the local tag, you’ll want to grab the latest tags from the remote repository to ensure you’re up to date. Use this command:

git fetch — all — tags

The ` — all` option fetches all branches from the remote, and ` — tags` ensures that all tags are pulled down.

Step 3: Check Out the New Tag

Now that you have the updated tags, you can check out the one you need:

git checkout tags/<tag-name>

This will check out the tag in a detached HEAD state, meaning you’re directly on the tag rather than on a branch.

Optional: Create a Branch from the Tag

If you need to make changes and prefer to be on a branch, you can create one from the tag like this:

git checkout -b <new-branch-name> tags/<tag-name>

For example:

git checkout -b feature-v1.0.0 tags/v1.0.0

This sets up a new branch based on the tag.

Happy Coding!

--

--

Tony Mucci
Code Kings

Co-founder of SimpliCourt, dree, My Company Tools, and Eklect Enterprises