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

Re: Ignoring remote branches.

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 12, 2010, 10:25 UTC
Message-ID
<20100512102512.GA17810@progeny.tock>
In-Reply-To
<9F4F3DE1-59FE-4D27-A40E-81856BF95C9D@gmail.com>
Hi Steven,
Steven Michalske wrote:
> I want to track new branches, so specifying the branches I want
> to fetch is tedious.
> 
> Any workarounds to ignore all branches that match *.stgit

I would suggest using ‘git ls-remote’ and ‘git fetch’ to grab just the branches you want.

  #!/bin/sh
  set -e
  : ${remote=origin}
  : ${options=--dry-run}
  script='!/\.stgit$/ s'
  script="${script}#.*\\trefs/heads/\\(.*\\)\$"
  script="${script}#git fetch $options $remote "
  script="${script} refs/heads/\\1:refs/remotes/$remote/\\1"
  script="${script}#p"
  eval "$(git ls-remote "$remote" | sed -n "$script")"

I am not sure how to generalize this: a pre-fetch hook that can reject some branch names? a fetchregexp configuration item?

 [remote "origin"]
	url = git://git.example.com/repo.git/
	fetchregexp = "refs/heads/\([^.]*\):refs/remotes/origin/\1"
Maybe we can solve some similar problems at the same time.

Thanks, Jonathan

Previous: Steven Michalske
Message 2 of 2 in “Ignoring remote branches.”
  1. Steven MichalskeMay 11, 2010
  2. Jonathan NiederMay 12, 2010

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.