How to delete git tag

How to delete git tag

Tagging

Listing Your Tags

This command lists the tags in alphabetical order; the order in which they are displayed has no real importance.

You can also search for tags that match a particular pattern. The Git source repo, for instance, contains more than 500 tags. If you’re interested only in looking at the 1.8.5 series, you can run this:

Creating Tags

Git supports two types of tags: lightweight and annotated.

A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

Annotated Tags

You can see the tag data along with the commit that was tagged by using the git show command:

That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information.

Lightweight Tags

This time, if you run git show on the tag, you don’t see the extra tag information. The command just shows the commit:

Tagging Later

You can also tag commits after you’ve moved past them. Suppose your commit history looks like this:

Now, suppose you forgot to tag the project at v1.2, which was at the “Update rakefile” commit. You can add it after the fact. To tag that commit, you specify the commit checksum (or part of it) at the end of the command:

You can see that you’ve tagged the commit:

Sharing Tags

Now, when someone else clones or pulls from your repository, they will get all your tags as well.

Deleting Tags

Note that this does not remove the tag from any remote servers. There are two common variations for deleting a tag from a remote server.

The first variation is git push :refs/tags/ :

The way to interpret the above is to read it as the null value before the colon is being pushed to the remote tag name, effectively deleting it.

The second (and more intuitive) way to delete a remote tag is with:

Checking out Tags

If you want to view the versions of files a tag is pointing to, you can do a git checkout of that tag, although this puts your repository in “detached HEAD” state, which has some ill side effects:

In “detached HEAD” state, if you make changes and then create a commit, the tag will stay the same, but your new commit won’t belong to any branch and will be unreachable, except by the exact commit hash. Thus, if you need to make changes — say you’re fixing a bug on an older version, for instance — you will generally want to create a branch:

If you do this and make a commit, your version2 branch will be slightly different than your v2.0.0 tag since it will move forward with your new changes, so do be careful.

How to delete a Git tag (locally and remotely)

Just in case I forget how to remove Git tags from a repo, I’m posting a short tutorial here for future reference.

In software development, Git tags represent a version of our code at a given moment in time. Unlike branches, tags are not mutable so people generally use them to mark important points in Git history, like release points (eg. v1.0.0 and so on).

At the same time, because Git tags are immutable and always point to the same commit you can’t change them, what if:

The history of software development is filled with oh-noes-I’m-an-idiot-for-not-paying-attention moments. We all have been there.

You could change whatever needs changing and then just tag a new version – but if that’s not an option (or if you feel like you won’t be able to live with the guilt) you can delete the tag, commit your changes and recreate the tag once more. Here’s how.

Removing a Git tag from a local repository

To delete a tag from your local repo, use the tag command followed by the -d (or –delete) option and the tag version/number:

Say for example that you wanted to delete a Git tag named 3.3.1 from your local repository. All you have to do is run this command:

If everything went OK you should see something like this on screen:

Removing a Git tag from a remote repository

If you have already pushed the tag to a remote repository (eg. GitHub) then you’ll also need to update the remote references right after deleting the tag from your local repository.

Following the same example from before, after deleting the local tag you’ll need to run this command to remove the tag from the remote repository as well:

Remember, 3.3.1 is the name of the tag we just deleted from our local repository.

After this the tag should be gone from the remote repository as well.

Leave a Reply

You need a more up-to-date browser to join the discussion.

Delete all tags from a Git repository

I want to delete all the tags from a Git repository. How can I do that?

But I see that * means the files from the current directory.

Consider I have a lot of tags, and I want to delete them, all.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

17 Answers 17

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

Simply follow the Unix philosophy where you pipe everything.

On Windows use git bash with the same command.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

To delete remote tags (before deleting local tags) simply do:

and then delete the local copies:

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

It may be more efficient to push delete all the tags in one command. Especially if you have several hundred.

In a suitable non-windows shell, delete all remote tags:

Then delete all local tags:

This should be OK as long as you don’t have a ‘ in your tag names. For that, the following commands should be OK.

Other ways of taking a list of lines, wrapping them in quotes, making them a single line and then passing that line to a command probably exist. Considering this is the ultimate cat skinning environment and all.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

For Windows users using PowerShell:

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

If you don’t have the tags in your local repo, you can delete remote tags without have to take it to your local repo.

Don’t forget to replace «origin» to your remote handler name.

Adding to Stefan’s answer which was missing how to delete tags from remote. For windows powershell you can run this to delete the remote tags first followed by the local tags.

For windows users:

You can also use:

I have to delete the tags with prefix

for example, I have to delete the tags v0.0.1, v0.0.2, v0.0.3, v0.0.4, v0.0.5

Decompose and explain the statement above:

To list all the tags with prefix

That’s how that statement works

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

To delete all the local tags simple run the following command

To delete remote tags after deleting the local tags by running the above command, you can run the comand below

NOTE: replace origin with your remote handler

Since all these options only work in linux, here’s the windows equivalent for anybody having to deal with that:

Powershell v7 supports parallel foreach if you have lots of upstream (origin) tags that you need to delete:

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

Recent version parallelized and filtered

First line, remove all matching tags from remote in parallel.
Second line, update the current repo by pruning all deleted tags, from git version v2.26.2.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

Show all tags containing «v»

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

A one liner that deletes both local and remote tags with a wild card pattern.

Remote tags are deleted first as the list is generated from local.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

It takes advantage of the fact that you can provide multiple tag names in a space delimited string, so it only invokes git delete once.

Работа с тегами

Как и большинство СКВ, Git имеет возможность помечать определённые моменты в истории как важные. Как правило, эта функциональность используется для отметки моментов выпуска версий (v1.0, и т. п.). Такие пометки в Git называются тегами. В этом разделе вы узнаете, как посмотреть имеющиеся теги, как создать новые или удалить существующие, а также какие типы тегов существуют в Git.

Просмотр списка тегов

Данная команда перечисляет теги в алфавитном порядке; порядок их отображения не имеет существенного значения.

Так же можно выполнить поиск тега по шаблону. Например, репозиторий Git содержит более 500 тегов. Если вы хотите посмотреть теги выпусков 1.8.5, то выполните следующую команду:

Создание тегов

Git использует два основных типа тегов: легковесные и аннотированные.

Легковесный тег — это что-то очень похожее на ветку, которая не изменяется — просто указатель на определённый коммит.

А вот аннотированные теги хранятся в базе данных Git как полноценные объекты. Они имеют контрольную сумму, содержат имя автора, его e-mail и дату создания, имеют комментарий и могут быть подписаны и проверены с помощью GNU Privacy Guard (GPG). Обычно рекомендуется создавать аннотированные теги, чтобы иметь всю перечисленную информацию; но если вы хотите сделать временную метку или по какой-то причине не хотите сохранять остальную информацию, то для этого годятся и легковесные.

Аннотированные теги

С помощью команды git show вы можете посмотреть данные тега вместе с коммитом:

Здесь приведена информация об авторе тега, дате его создания и аннотирующее сообщение перед информацией о коммите.

Легковесные теги

На этот раз при выполнении git show для этого тега вы не увидите дополнительной информации. Команда просто покажет коммит:

Отложенная расстановка тегов

Также возможно помечать уже пройденные коммиты. Предположим, история коммитов выглядит следующим образом:

Теперь предположим, что вы забыли отметить версию проекта v1.2, которая была там, где находится коммит «Update rakefile». Вы можете добавить тег и позже. Для отметки коммита укажите его контрольную сумму (или её часть) как параметр команды:

Проверим, что коммит отмечен:

Обмен тегами

Теперь, если кто-то клонирует (clone) или выполнит git pull из вашего репозитория, то он получит вдобавок к остальному и ваши метки.

Удаление тегов

Обратите внимание, что при удалении тега не происходит его удаления с внешних серверов. Существует два способа изъятия тега из внешнего репозитория.

Первый способ — это выполнить команду git push :refs/tags/ :

Это следует понимать как обновление внешнего тега пустым значением, что приводит к его удалению.

Второй способ убрать тег из внешнего репозитория более интуитивный:

Переход на тег

Если вы хотите получить версии файлов, на которые указывает тег, то вы можете сделать git checkout для тега. Однако, это переведёт репозиторий в состояние «detached HEAD», которое имеет ряд неприятных побочных эффектов.

Если в состоянии «detached HEAD» внести изменения и сделать коммит, то тег не изменится, при этом новый коммит не будет относиться ни к какой из веток, а доступ к нему можно будет получить только по его хешу. Поэтому, если вам нужно внести изменения — исправить ошибку в одной из старых версий — скорее всего вам следует создать ветку:

Managing tags

In this article

You can use GitHub Desktop to create, push, and view tags.

About tags in GitHub Desktop

GitHub Desktop allows you to create annotated tags. Tags are associated with commits, so you can use a tag to mark an individual point in your repository’s history, including a version number for a release. For more information about release tags, see «About releases.»

By default, GitHub Desktop will push the tag that you create to your repository with the associated commit.

Click History. How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

Click the commit.

Note: GitHub Desktop displays an arrow

if the tag has not been pushed to the remote repository.

How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

All tags associated with the commit are visible in that commit’s metadata. How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

Note: You can only delete tags associated with commits that have not yet been pushed.

Click History. How to delete git tag. Смотреть фото How to delete git tag. Смотреть картинку How to delete git tag. Картинка про How to delete git tag. Фото How to delete git tag

Right-click the commit.

Help us make these docs great!

All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *