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

Re: Update a bare repository

From
Jeff King <peff@peff.net>
Date
Jul 17, 2007, 07:04 UTC
Message-ID
<20070717070428.GA13266@coredump.intra.peff.net>
In-Reply-To
<20070717063026.GA5823@cip.informatik.uni-erlangen.de>
On Tue, Jul 17, 2007 at 08:30:26AM +0200, Thomas Glanzmann wrote:
Show 5 quoted lines
> I have a _bare_ clone of a git repository and would like to update it
> from Junios repository at kernel.org from time to time.
> [...]
> "git pull" does not work. "git fetch" does, but it does update all
> references?

You don't want to pull because that involves merging, which doesn't make sense. A git-fetch is what you want, and you can use wildcards to make sure you get all of the refs. The default is something like this:

[remote "origin"]
  url = git://git2.kernel.org/pub/scm/git/git.git
  fetch = +refs/heads/*:refs/remotes/origin/*

However, if you are intending to make this an _exact_ copy of Junio's (because you will be fetching from it with your other, non-bare repos), then you probably don't want the "separate remotes" layout. You want to copy the refs with the same names:

[remote "origin"]
  url = git://git2.kernel.org/pub/scm/git/git.git
  fetch = +refs/heads/*:refs/heads/*

The "+" in both cases means that it copies whatever Junio has, even if it might lose some commits of yours. But that seems to be what you want in this case.

> I also would like to check that it is impossible to push anything to the
> repository.

The simplest thing is not to give write access to the repo for your pushers. However, you could also put in a pre-receive hook that rejects all pushes.

-Peff
Previous: Thomas GlanzmannNext: Thomas Glanzmann
Message 2 of 5 in “Update a bare repository”
  1. Thomas GlanzmannJul 17, 2007
  2. Jeff KingJul 17, 2007
  3. Thomas GlanzmannJul 17, 2007
  4. Jeff KingJul 17, 2007
  5. Thomas GlanzmannJul 17, 2007

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.