git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Update a bare repository
@ 2007-07-17  6:30 Thomas Glanzmann
  2007-07-17  7:04 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Glanzmann @ 2007-07-17  6:30 UTC (permalink / raw)
  To: GIT

Hello,
what I would like to do is the following:

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.

How do I do that? In a way that it is a fire and forget solution? It
should also fetch new upstream branches.

"git pull" does not work. "git fetch" does, but it does update all
references?

	(faui02) [~/work/repositories/mirror/git.git] git pull
	fatal: /usr/bin/git-pull cannot be used without a working tree.
	(faui02) [~/work/repositories/mirror/git.git] git fetch
	(faui02) [~/work/repositories/mirror/git.git]

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

		Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update a bare repository
  2007-07-17  6:30 Update a bare repository Thomas Glanzmann
@ 2007-07-17  7:04 ` Jeff King
  2007-07-17  7:26   ` Thomas Glanzmann
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2007-07-17  7:04 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: GIT

On Tue, Jul 17, 2007 at 08:30:26AM +0200, Thomas Glanzmann wrote:

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update a bare repository
  2007-07-17  7:04 ` Jeff King
@ 2007-07-17  7:26   ` Thomas Glanzmann
  2007-07-17  7:31     ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Glanzmann @ 2007-07-17  7:26 UTC (permalink / raw)
  To: Jeff King; +Cc: GIT

Hello,

> 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.

thanks a lot. That is exactly what I was looking for.

> 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.

Is there an example somewhere?

	Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update a bare repository
  2007-07-17  7:26   ` Thomas Glanzmann
@ 2007-07-17  7:31     ` Jeff King
  2007-07-17  7:41       ` Thomas Glanzmann
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2007-07-17  7:31 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: GIT

On Tue, Jul 17, 2007 at 09:26:35AM +0200, Thomas Glanzmann wrote:

> > 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.
> 
> Is there an example somewhere?

Not that I know of, but it should be as simple as:

echo "echo Sorry, no pushing allowed.; exit 1" >.git/hooks/pre-receive
chmod +x .git/hooks/pre-receive

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update a bare repository
  2007-07-17  7:31     ` Jeff King
@ 2007-07-17  7:41       ` Thomas Glanzmann
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Glanzmann @ 2007-07-17  7:41 UTC (permalink / raw)
  To: Jeff King; +Cc: GIT

Hello Peff,

> echo "echo Sorry, no pushing allowed.; exit 1" >.git/hooks/pre-receive
> chmod +x .git/hooks/pre-receive

thank you, that does exactly what I wanted:

	(faui03) [/var/tmp/git] git commit -a
	Created commit 9e89d1d: added some whitespace
	1 files changed, 1 insertions(+), 0 deletions(-)
	(faui03) [/var/tmp/git] git push origin
	updating 'refs/heads/master'
	from 9dfdf14b3805e89aa2782458bda15b3dfae24c09
	to   9e89d1d3890c6b0fd8546143a6e797820e274cb1
	Generating pack...
	Done counting 5 objects.
	Result has 3 objects.
	Deltifying 3 objects...
	100% (3/3) done
	Writing 3 objects...
	100% (3/3) done
	Total 3 (delta 2), reused 0 (delta 0)
	Sorry, no pushing allowed.
	error: hooks/pre-receive exited with error code 1
	ng refs/heads/master pre-receive hook declined
	error: failed to push to '131.188.30.103:/home/cip/adm/sithglan/work/repositories/mirror/git.git'

		Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-17  7:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17  6:30 Update a bare repository Thomas Glanzmann
2007-07-17  7:04 ` Jeff King
2007-07-17  7:26   ` Thomas Glanzmann
2007-07-17  7:31     ` Jeff King
2007-07-17  7:41       ` Thomas Glanzmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).