Update a bare repository

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

Update a bare repository

From: Thomas Glanzmann <hidden>
Date: 2016-06-15 22:43:21

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

Re: Update a bare repository

From: Jeff King <hidden>
Date: 2016-06-15 22:43:21

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

Re: Update a bare repository

From: Thomas Glanzmann <hidden>
Date: 2016-06-15 22:43:21

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

Re: Update a bare repository

From: Jeff King <hidden>
Date: 2016-06-15 22:43:21

On Tue, Jul 17, 2007 at 09:26:35AM +0200, Thomas Glanzmann wrote:
quoted
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

Re: Update a bare repository

From: Thomas Glanzmann <hidden>
Date: 2016-06-15 22:43:21

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help