'Cannot delete Git tags which have special characters
$ git tag
+"feature/04-28_v001-11"+
+"feature/04-28_v001-19"+
Above git tags not able to delete since + and " exist in the tags.
Solution 1:[1]
The error message
error: cannot lock ref 'refs/tags/+"feature/04-28_v001-11"+': unable to create directory for .git/refs/tags/+"feature/04-28_v001-11"+
indicates that you are not operating on POSIX. I assume you are on Windows.
As the error message indicates, Git is unable to create a directory containing the doublequote character. The conclusion is that the tag does not exist on the filesystem, but only in the packed-refs file.
WARNING: The following suggests a method to fix your problem, but you are messing with Git's database. Be sure to have a backup of the repository before you continue.
Before you continue, be sure the the repository is quiescent. No Git operations must be on-going. Close all UIs including code editors and IDEs that would access the repository.
Now, make a backup of the file
.git/packed-refs
just in case you break something.
To remove the tag, edit this file with a modern source code editor that can cope with Unix-style line-terminators (LF instead of CRLF) (any editor but Notepad will do). Look up the lines mentioning the tags, and delete the lines and the lines following them if they begin with the caret ^
.
That is, when you start with
# pack-refs with: peeled fully-peeled sorted
9e72299d[...] refs/heads/master
57689754[...] refs/tags/bad/one
^b73b6860[...]
03706a09[...] refs/tags/bad/two
^ed20caaf[...]
f9d1d51c[...] refs/tags/good/one
^4974cb42[...]
you remove the bad
ones, you should end with
# pack-refs with: peeled fully-peeled sorted
9e72299d[...] refs/heads/master
f9d1d51c[...] refs/tags/good/one
^4974cb42[...]
Call git tag
to verify the result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |