{"thread":{"id":"9067","subject":"Update a bare repository","startedAt":"2007-07-17T06:30:26Z","lastAt":"2007-07-17T07:41:12Z","messageCount":5,"participants":["Thomas Glanzmann","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"47613","messageId":"20070717063026.GA5823@cip.informatik.uni-erlangen.de","threadId":"9067","inReplyTo":null,"subject":"Update a bare repository","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-07-17T06:30:26Z","receivedAt":"2007-07-17T06:30:26Z","isPatch":false,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello,\nwhat I would like to do is the following:\n\nI have a _bare_ clone of a git repository and would like to update it\nfrom Junios repository at kernel.org from time to time.\n\nHow do I do that? In a way that it is a fire and forget solution? It\nshould also fetch new upstream branches.\n\n\"git pull\" does not work. \"git fetch\" does, but it does update all\nreferences?\n\n\t(faui02) [~/work/repositories/mirror/git.git] git pull\n\tfatal: /usr/bin/git-pull cannot be used without a working tree.\n\t(faui02) [~/work/repositories/mirror/git.git] git fetch\n\t(faui02) [~/work/repositories/mirror/git.git]\n\nI also would like to check that it is impossible to push anything to the\nrepository.\n\n\t\tThomas\n"},{"id":"47614","messageId":"20070717070428.GA13266@coredump.intra.peff.net","threadId":"9067","inReplyTo":"20070717063026.GA5823@cip.informatik.uni-erlangen.de","subject":"Re: Update a bare repository","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-17T07:04:29Z","receivedAt":"2007-07-17T07:04:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 17, 2007 at 08:30:26AM +0200, Thomas Glanzmann wrote:\n\n> I have a _bare_ clone of a git repository and would like to update it\n> from Junios repository at kernel.org from time to time.\n> [...]\n> \"git pull\" does not work. \"git fetch\" does, but it does update all\n> references?\n\nYou don't want to pull because that involves merging, which doesn't make\nsense. A git-fetch is what you want, and you can use wildcards to make\nsure you get all of the refs. The default is something like this:\n\n[remote \"origin\"]\n  url = git://git2.kernel.org/pub/scm/git/git.git\n  fetch = +refs/heads/*:refs/remotes/origin/*\n\nHowever, if you are intending to make this an _exact_ copy of Junio's\n(because you will be fetching from it with your other, non-bare repos),\nthen you probably don't want the \"separate remotes\" layout. You want to\ncopy the refs with the same names:\n\n[remote \"origin\"]\n  url = git://git2.kernel.org/pub/scm/git/git.git\n  fetch = +refs/heads/*:refs/heads/*\n\nThe \"+\" in both cases means that it copies whatever Junio has, even if\nit might lose some commits of yours. But that seems to be what you want\nin this case.\n\n> I also would like to check that it is impossible to push anything to the\n> repository.\n\nThe simplest thing is not to give write access to the repo for your\npushers. However, you could also put in a pre-receive hook that rejects\nall pushes.\n\n-Peff\n"},{"id":"47615","messageId":"20070717072635.GG5823@cip.informatik.uni-erlangen.de","threadId":"9067","inReplyTo":"20070717070428.GA13266@coredump.intra.peff.net","subject":"Re: Update a bare repository","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-07-17T07:26:35Z","receivedAt":"2007-07-17T07:26:35Z","isPatch":false,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello,\n\n> The \"+\" in both cases means that it copies whatever Junio has, even if\n> it might lose some commits of yours. But that seems to be what you\n> want in this case.\n\nthanks a lot. That is exactly what I was looking for.\n\n> The simplest thing is not to give write access to the repo for your\n> pushers. However, you could also put in a pre-receive hook that rejects\n> all pushes.\n\nIs there an example somewhere?\n\n\tThomas\n"},{"id":"47617","messageId":"20070717073115.GA14629@coredump.intra.peff.net","threadId":"9067","inReplyTo":"20070717072635.GG5823@cip.informatik.uni-erlangen.de","subject":"Re: Update a bare repository","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-17T07:31:15Z","receivedAt":"2007-07-17T07:31:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 17, 2007 at 09:26:35AM +0200, Thomas Glanzmann wrote:\n\n> > The simplest thing is not to give write access to the repo for your\n> > pushers. However, you could also put in a pre-receive hook that rejects\n> > all pushes.\n> \n> Is there an example somewhere?\n\nNot that I know of, but it should be as simple as:\n\necho \"echo Sorry, no pushing allowed.; exit 1\" >.git/hooks/pre-receive\nchmod +x .git/hooks/pre-receive\n\n-Peff\n"},{"id":"47618","messageId":"20070717074112.GH5823@cip.informatik.uni-erlangen.de","threadId":"9067","inReplyTo":"20070717073115.GA14629@coredump.intra.peff.net","subject":"Re: Update a bare repository","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-07-17T07:41:12Z","receivedAt":"2007-07-17T07:41:12Z","isPatch":false,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello Peff,\n\n> echo \"echo Sorry, no pushing allowed.; exit 1\" >.git/hooks/pre-receive\n> chmod +x .git/hooks/pre-receive\n\nthank you, that does exactly what I wanted:\n\n\t(faui03) [/var/tmp/git] git commit -a\n\tCreated commit 9e89d1d: added some whitespace\n\t1 files changed, 1 insertions(+), 0 deletions(-)\n\t(faui03) [/var/tmp/git] git push origin\n\tupdating 'refs/heads/master'\n\tfrom 9dfdf14b3805e89aa2782458bda15b3dfae24c09\n\tto   9e89d1d3890c6b0fd8546143a6e797820e274cb1\n\tGenerating pack...\n\tDone counting 5 objects.\n\tResult has 3 objects.\n\tDeltifying 3 objects...\n\t100% (3/3) done\n\tWriting 3 objects...\n\t100% (3/3) done\n\tTotal 3 (delta 2), reused 0 (delta 0)\n\tSorry, no pushing allowed.\n\terror: hooks/pre-receive exited with error code 1\n\tng refs/heads/master pre-receive hook declined\n\terror: failed to push to '131.188.30.103:/home/cip/adm/sithglan/work/repositories/mirror/git.git'\n\n\t\tThomas\n"}]}