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

Re: Best way to specify all local branches and all remote branches.

From
PGPaul Gardiner <osronline@glidos.net>
Date
Feb 11, 2008, 19:40 UTC
Message-ID
<47B0A4B6.2090408@glidos.net>
In-Reply-To
<m3ir0ve2c1.fsf@localhost.localdomain>
Jakub Narebski wrote:
Show 9 quoted lines
> Paul Gardiner <osronline@glidos.net> writes:
> 
>> New to git, and often finding it hard to specify the correct
>> refs for a command. Here's an example where I was converting
>> all the files in all the commits from unix line endings to
>> DOS line endings. You can see I've ended up using cd and ls.
>> I'm sure there must be a better way.
> 
> git-for-each-ref, git-show-ref, git-ls-remote / git-peek-remote.
Ah right, those look hellishly useful, thanks.
Show 12 quoted lines
>> $ cd /home/public/tmp/git/
>> $ yes |rm -r vdos32
>> $ git clone /export/git/vdos32.git vdos32
>> $ cd vdos32/
>> $ for f in `(cd /export/git/vdos32.git/refs/heads; ls)|sed -e
>>     '/master/d' -e '/origin/d'`; do git fetch origin $f:$f; done
>> $ git-filter-branch --tag-name-filter cat --tree-filter 'find . -type f
>>     ! -name \*.gif ! -name \*.ico|xargs unix2dos -q' `(cd
>>     .git/refs/heads;ls)`
> 
> If you want to fetch all branches, you can specify globbing refspec;
> of course if you use separate remotes layout, or mirror layout.

I think I tried that with my line 5 above. I tried refs/heads/*:refs/heads/* as the ref spec. Should something like that work?

Show 7 quoted lines
> If you want to pass all branches to git command, usually --all would
> be enough (sometimes --heads).
>  
>> With git-filter-branch, I'm surprised I can't use --all.
> 
> git-filter-branch is about single branch; I'm not sure if it should
> support --all.

It seems to work with multiple branches, and I think it's important that it does, because as far as I can tell, that's the only way to filter a whole repository without visiting some commits more than once. Certainly my command, using cd/ls, worked and visited each commit exactly once.

Cheers,
	Paul.
Previous: Jakub NarebskiNext: Johannes Schindelin
Message 3 of 6 in “Best way to specify all local branches and all remote branches.”
  1. Paul GardinerFeb 11, 2008
  2. Jakub NarebskiFeb 11, 2008
  3. Paul GardinerFeb 11, 2008
  4. Johannes SchindelinFeb 11, 2008
  5. Paul GardinerFeb 11, 2008
  6. Jakub NarebskiFeb 11, 2008

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.