Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
99 views
in Technique[技术] by (71.8m points)

How to get list of latest tags in remote git?

There are alot of methods to get latest tags when you have local git repo.

But i want to get list of latest tags on remote repo.

I know about "git ls-remote", and everything is fine when you use tags like x.y.z (where x,y,z are numbers). But when tags looks like "test-x.y.z" and "dev-x.y.z" i noticed that large amount of "test" tags will pull out any new "dev" tags, which is not correct.

So, how would you like solve this?

question from:https://stackoverflow.com/questions/20734181/how-to-get-list-of-latest-tags-in-remote-git

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With Git 2.18 (Q2 2018), git ls-remote learned an option to allow sorting its output based on the refnames being shown.

See commit 1fb20df (09 Apr 2018) by Harald Nordgren (HaraldNordgren).
(Merged by Junio C Hamano -- gitster -- in commit 6c0110f, 08 May 2018)

ls-remote: create '--sort' option

Create a '--sort' option for ls-remote, based on the one from for-each-ref.
This e.g. allows ref names to be sorted by version semantics, so that v1.2 is sorted before v1.10.

So check out those for-each-ref --sort options introduced in Git 2.0 and 2.8, because they apply now to git ls-remote --sort.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...