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

Re: when is a remote a branch?

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 12, 2006, 16:11 UTC
Message-ID
<ej7h1n$ed8$1@sea.gmane.org>
In-Reply-To
<ej7fra$8ca$2@sea.gmane.org>
Anand Kumria wrote:
Show 9 quoted lines
> I generally tend to use cogito -- it does all the heavy lifting, like
> recovering from interrupted fetchs (usually) for me.  One thing I haven't
> really gotten my head around is the difference between a branch and a
> remote.
> 
> git-branch knows of 'remotes' (via the -r parameter) and these to be
> unrelated to what cogito thinks remotes are (it seems to look for things
> in .git/refs/head/<name> and then a corresponding .git/branches/<name>/
> which it then declares a remote).

Not about 'remotes', but about 'remote [read-only] branches', i.e. refs not from .refs/heads/, but from .refs/remotes/<remotename>/

Show 6 quoted lines
> Yet, git-init-db creates both .git/remotes and .git/branches
> 
> What is the difference between the two. From my (na?ve) perspective the
> two tools (git and cogito) regarded them very differently.
> 
> Any explanation, or pointer to some documentation, would be helpful.

Read Documentation/repository-layout.txt (ot it's HTML version, either locally ot at www.kernel.org).

 branches::
         A slightly deprecated way to store shorthands to be used
         to specify URL to `git fetch`, `git pull` and `git push`
         commands is to store a file in `branches/'name'` and
         give 'name' to these commands in place of 'repository'
         argument.

You can store only one branch to fetch per shorthand. I'm not sure about where it is stored which branch to download, and how to name this branch locally.

 remotes::
         Stores shorthands to be used to give URL and default
         refnames to interact with remote repository to `git
         fetch`, `git pull` and `git push` commands.
From Documentation/urls.txt
 In addition to the above, as a short-hand, the name of a
 file in `$GIT_DIR/remotes` directory can be given; the
 named file should be in the following format:
         URL: one of the above URL format
         Push: <refspec>
         Pull: <refspec>

Currently there is yet another way, by using config file: (also from Documentation/urls.txt):

 Or, equivalently, in the `$GIT_DIR/config` (note the use
 of `fetch` instead of `Pull:`):
 [remote "<remote>"]
         url = <url>
         push = <refspec>
         fetch = <refspec>
where <refspec> is defined in Documentation/fetch-pull-param.txt
 <refspec>::
         The canonical format of a <refspec> parameter is
         `+?<src>:<dst>`; that is, an optional plus `+`, followed
         by the source ref, followed by a colon `:`, followed by
         the destination ref.

(or, simply, in git-pull(1), which includes those files, with exception of repository layout document).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Anand KumriaNext: Petr Baudis
Message 2 of 7 in “when is a remote a branch?”
  1. Anand KumriaNov 12, 2006
  2. Jakub NarebskiNov 12, 2006
  3. Petr BaudisNov 12, 2006
  4. Jakub NarebskiNov 12, 2006
  5. Petr BaudisNov 14, 2006
  6. Jakub NarebskiNov 14, 2006
  7. Petr BaudisNov 14, 2006

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.