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

Re: git tag --no-merged?

From
Kyle J. McKay <mackyle@gmail.com>
Date
Feb 5, 2015, 00:22 UTC
Message-ID
<6A0F0356-2AF1-487D-A20E-FB6051D9E689@gmail.com>
In-Reply-To
<alpine.DEB.2.00.1502041615110.30476@ds9.cixit.se>
On Feb 4, 2015, at 07:19, Peter Krefting wrote:
> Using "git branch --no-merged" I can get a list of branches that I  
> have that I haven't merged into my current branch. "git tag" doesn't  
> have such an option, is there a way to achieve something similar  
> listing tags that point to commits that aren't in my history?
I think something like this might do what you want:
git for-each-ref --format='%(refname)' refs/tags | \
while read t; do
   if ! git merge-base --is-ancestor $t HEAD; then
     echo ${t#refs/tags/}
   fi
done

If you run that on the Git repository (assuming you've checked out master), after a while (there are a lot of tags to check) it spits out v1.4.4.5 (along with some complaints about *-gpg-pub tags that refer to blobs).

And sure enough, `git log v1.4.4.5 ^master` shows 5 commits not contained in master so I think it does what you want. You'll want to restrict the for-each-ref output further, if possible, to make it quicker.

-Kyle
Previous: Junio C HamanoNext: Peter Krefting
Message 5 of 6 in “git tag --no-merged?”
  1. Peter KreftingFeb 4, 2015
  2. Junio C HamanoFeb 4, 2015
  3. Johannes SixtFeb 4, 2015
  4. Junio C HamanoFeb 4, 2015
  5. Kyle J. McKayFeb 5, 2015
  6. Peter KreftingFeb 5, 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.