5

I have a small problem at work.

We commit all the different projects to different remote repositories and sometimes people get confused by the names they create at 4 in the morning high on caffeine.

So my question is:

Is there a way to browse remote repositories to list all the branches?

Any help is greatly appreciated!

RobinNilsson
  • 488
  • 1
  • 15
  • 26
  • 2
    Your question title asks about "remote repository" but your question body asks about "remote branches". "Remote branches" are just branches named remote/(whatever), in a local repository. Be careful to distinguish between these. Commands like "git log" and "git branch -a" only look at the *local* repo; it's only commands like "git fetch" and "git remote update" that use ssh, http, ftp, etc to obtain things from a *remote* repo. – torek May 27 '13 at 19:05
  • 1
    Ah yes, sorry about that! I confused that for a moment there. Good catch. What I want is to brows a remote repository for branches! I will edit in a minute! – RobinNilsson May 27 '13 at 19:07

3 Answers3

3

To list only remote branches, first fetch (to ensure you have a local reference to them all), then list them:

git fetch
git branch -r

You may wish to, after fetching, do a git remote prune <remotename> (where <remotename> is the name of your remote—usually origin) to remove obsolete local references to remote branches that have been deleted.

The only way to directly “browse” a remote repository is to log into the server it resides on and do so (or setup gitweb or similar). Git is centered around the idea that your local copy has everything the remote does.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
  • Ah yes, that does what I'm looking for. I realize that I have to use a git web interface to get some structure here! Thanks! (I've used all my upvotes for today, but expect one tomorrow!). – RobinNilsson May 27 '13 at 19:28
  • So basically, you and Łukasz Niemier are saying that we need to download a copy of the remote repository (**git fetch**) to see what's in it. I was hoping there was a way of doing that without doing the download. – Edward Falk May 28 '13 at 06:10
  • @EdwardFalk Yes, as I say in my answer, Git is all about your local copy being a complete representation of the remote. – Andrew Marshall May 28 '13 at 17:31
1

git branch -a will list all branches, local and remote tracking.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • Sorry I was confused for a moment there, I totally screwed up my question. I ofc meant browse a remote repository, not a local branch as @torek noticed. – RobinNilsson May 27 '13 at 19:12
  • Thanks @hd1, I've accepted Andrew Marshall's answer. I have used up all my upvotes for today, but you sure will get one tomorrow! ^^ – RobinNilsson May 27 '13 at 19:29
  • OTOH, even gitblit works from a bare repository, at least by default – hd1 May 28 '13 at 15:16
0

If you fetch all branches using git fetch --all then you can view all remote branches using:

git branch -a | grep remote
Hauleth
  • 22,873
  • 4
  • 61
  • 112