Re: Find/prune local branches after upstream branch is deleted?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 19, 2013 at 12:50:48PM -0500, Jed Brown wrote:

> Jeff King <peff@xxxxxxxx> writes:
> 
> > Try "git branch --merged master" to get a list of branches that have
> > already been merged.
> 
> That's what I use, but I was hoping for something more precise.  For
> example, a branch that started at 'maint' would show up there, but its
> integration hasn't completed until it makes it back to 'maint'.

Yeah, git has no way of knowing that. You can tell it by asking "git
branch --merged maint" and looking for such topics, of course, but I
think you are trying to remove as much thinking as possible from the
process.

So what is the clue that you would like to use to know that the branch
is stale. Deletion of the branch on the remote?

For that, I don't think there is a single command. You can do "git push
--dry-run --all" and look for new branches that would be pushed, but
that is kind of hacky.  The answer you want is:

  comm -23 \
    <(git for-each-ref --format='%(refname:short)' refs/heads) \
    <(git for-each-ref --format='%(refname:short)' refs/remotes/origin |
      sed s,origin/,,)

You said you didn't want to script, but I think that is the only option
to answer that question cleanly.

Note that if you wrap that in an alias, you would want to use "bash -c",
as the <() syntax is not understood by many /bin/sh implementations.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]