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

Re: [PATCH] branch: introduce --(no-)has-upstream and --(no-)gone options

From
KKKonstantin Khomoutov <kostix@bswap.ru>
Date
Feb 17, 2023, 11:10 UTC
Message-ID
<20230217111036.yupfv4t6xn4xteah@carbon>
In-Reply-To
<CAMMLpeQgxPCTsWGr58rutSDnRuGAGcTXTvHLcgWAfzZjZGxakg@mail.gmail.com>
On Thu, Feb 16, 2023 at 08:12:08PM -0700, Alex Henrie wrote:
Show 24 quoted lines
> > >> GitHub and GitLab have features to create a branch using the web
> > >> interface, then delete the branch after it is merged. That results in a
> > >> lot of "gone" branches in my local clone, and I frequently find myself
> > >> typing `git branch -v | grep gone`. I don't want `git branch --merged`
> > >> because that would include branches that have been created for future
> > >> work but do not yet have any commits.
> > >
> > > Possibly a rather silly remark, but you could make a habit of periodically
> > > running
> > >
> > >   git remote prune <remotename>
> > >
> > > or fetching with "--prune".
> >
> > Likely to be a silly question, but isn't doing that, to actively
> > remove the remote tracking branches that correspond to branches that
> > no longer exist at the remote, exactly what gives Alex many local
> > branches that are marked as "gone" (i.e. forked from some upstream
> > sometime in the past, but the upstream no longer exists)?
> 
> Yes, the branches are marked [gone] precisely because I configured
> fetch.prune to true. So fetching automatically deletes the local
> copies of the upstream branches, but the local branches that track
> them are still there.
Ah, thanks, I see now.

I have a habit of always checking out remote branches directly when doing any work on them (they end up in a detached HEAD state), so I have sort of automagically evaded your problem not being aware of the fact.

Previous: Alex HenrieNext: Phillip Wood
Message 7 of 9 in “branch: introduce --(no-)has-upstream and --(no-)gone options”
  1. branch: introduce --(no-)has-upstream and --(no-)gone optionsAlex Henrie, Feb 16, 2023
  2. Junio C HamanoFeb 16, 2023
  3. Alex HenrieFeb 17, 2023
  4. Konstantin KhomoutovFeb 16, 2023
  5. Junio C HamanoFeb 16, 2023
  6. Alex HenrieFeb 17, 2023
  7. Konstantin KhomoutovFeb 17, 2023
  8. Phillip WoodFeb 17, 2023
  9. Junio C HamanoFeb 17, 2023

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.