Skip to content
Advertisement

Grep out tags from git repo

Trying to sed out the different tags from my repo with shell:

git ls-remote --tags git@mit.usa.com:s1836/pro-ti.git | awk '{print $2}'

Returns, How can I grep out only the different tags as v1, v2, v3, v4:

refs/tags/v1
refs/tags/v1^{}
refs/tags/v2
refs/tags/v2^{}
refs/tags/v3
refs/tags/v3^{}
refs/tags/v4
refs/tags/v4^{}

Advertisement

Answer

What about good old grep and uniq :

... | grep -o 'v[0-9]+' | sort | uniq
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement