git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: List tags for a certain branch

From
Jeff King <peff@peff.net>
Date
Aug 23, 2015, 17:07 UTC
Message-ID
<20150823170751.GA24194@sigill.intra.peff.net>
In-Reply-To
<55D9E672.4050503@gmx.de>
On Sun, Aug 23, 2015 at 05:27:46PM +0200, CoDEmanX wrote:
Show 19 quoted lines
> the question how to list tags, that point to commits contained in a certain
> branch came up on StackOverflow couple times, and this appears to be the
> only fast solution (example for local devel branch):
> 
>     git log --simplify-by-decoration --decorate --pretty=%d
> "refs/heads/devel" | fgrep 'tag: '
> 
> It would be much much simpler, if the tag command supporter an optional
> parameter to specify a branch:
> 
>     git tag --list --branch devel
> 
> It should result in something like:
> 
> Test-Tag1
> Test-Tag2
> Test-Tag3
> Another-Tag
> And-Another

I think the option you are looking for is "--merged", which currently only the "branch" command nows about. So right now you can do:

  git branch --merged devel

to get a list of branches that are contained in "devel". There is work underway to unify the selection/filter code for git-branch and git-tag, so in a future version of git you should be able to do "git tag --merged" to get the tags that are "merged" to a particular branch.

-Peff

PS I'm not sure if we should pick a more generic name than "--merged" when git-tag learns this feature. For branches, it makes sense to ask "which branches are merged to this other branch". But the operation is really "which items are ancestors of the commit I gave". It is the opposite of "--contains" in that sense. Sort of a "--contained-in".

Previous: CoDEmanXNext: CoDEmanX
Message 2 of 4 in “List tags for a certain branch”
  1. CoDEmanXAug 23, 2015
  2. Jeff KingAug 23, 2015
  3. CoDEmanXAug 23, 2015
  4. Jeff KingAug 23, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.