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

Re: Pushing a git repository to a new server

From
Ethan Reesor <firelizzard@gmail.com>
Date
Feb 11, 2013, 18:18 UTC
Message-ID
<CAE_TNi=NW1F3ZjYD3CF6y5qRb=6eQwdmX2ZY4g0SExn-k7Ez-g@mail.gmail.com>
In-Reply-To
<20130211164518.ad0a21aff672ad0e4f03a6bb@domain007.com>

On Mon, Feb 11, 2013 at 7:45 AM, Konstantin Khomoutov <kostix+git@007spb.ru> wrote: [...]

Show 38 quoted lines
> OK, here's the sketch.
> On the server, in the home directory of your "git" user, you create a
> wrapper around git-receive-pack, like this:
>
> # mkdir ~git/git-shell-commands
> # cat >~git/git-shell-commands/git-receive-new-repo
> #!/bin/sh
>
> set -e -u
>
> if [ $# -ne 1 ]; then
>         echo 'Missing required argument: <directory>' >&2
>         exit 1
> fi
>
> mkdir "$1" && git init --quiet --bare "$1" && git-receive-pack "$1"
> ^D
> # chmod +x $_
>
> Then, on the client side, to push a new repo, you just do
>
> $ git push --receive-pack=git-receive-new-repo --all git@server:repo.git
>
> This will make `git push` to spawn not just `git receive-pack <dir>` as
> it usually does but your wrapper, which would first create and
> initialize a bare repository and then spawn `git receive-pack` on it
> which would then communicate with the client side and receive
> everything from it.
>
> You could then create a client-side wrapper script or a Git alias for
> such "creative pushing", like this:
>
> $ git config --add --global alias.push-new-repo \
>   'push --receive-pack=git-receive-new-repo --all'
>
> So the whole client call is now reduced to
>
> $ git push-new-repo git@server:repo.git
Thanks, that's what I was going for.
Previous: Konstantin KhomoutovNext: Jeff King
Message 5 of 10 in “Pushing a git repository to a new server”
  1. Ethan ReesorFeb 10, 2013
  2. Konstantin KhomoutovFeb 11, 2013
  3. Ethan ReesorFeb 11, 2013
  4. Konstantin KhomoutovFeb 11, 2013
  5. Ethan ReesorFeb 11, 2013
  6. Jeff KingFeb 11, 2013
  7. Ethan ReesorFeb 11, 2013
  8. Michael J GruberFeb 12, 2013
  9. Jeff KingFeb 12, 2013
  10. Michael J GruberFeb 13, 2013

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.