git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khomoutov <kostix+git@007spb.ru>
To: Ethan Reesor <firelizzard@gmail.com>
Cc: Konstantin Khomoutov <kostix+git@007spb.ru>, git <git@vger.kernel.org>
Subject: Re: Pushing a git repository to a new server
Date: Mon, 11 Feb 2013 16:45:18 +0400	[thread overview]
Message-ID: <20130211164518.ad0a21aff672ad0e4f03a6bb@domain007.com> (raw)
In-Reply-To: <CAE_TNin6-weutRDToZ7-BBGJTCcf0dwJn0ChUbFcACRU=SbjzA@mail.gmail.com>

On Mon, 11 Feb 2013 02:57:51 -0500
Ethan Reesor <firelizzard@gmail.com> wrote:

[...]
> I want to create a git-command that 1) creates a bare version of the
> current repo, 2) and uploads it to the specified path on my server
> (using tar, but that's not the point).

Thanks, it's now a bit more clear.

> My problem is that I have no idea how things like git-push works via a
> user with git-shell. Can you only run certain git commands, like
> git-upload-pack?
[...]

Precisely so.  With additional twist that you can create (or link)
other commands under ~/git-shell-commands, and these will be available
as well.

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

  reply	other threads:[~2013-02-11 12:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10 21:00 Pushing a git repository to a new server Ethan Reesor
2013-02-11  7:50 ` Konstantin Khomoutov
2013-02-11  7:57   ` Ethan Reesor
2013-02-11 12:45     ` Konstantin Khomoutov [this message]
2013-02-11 18:18       ` Ethan Reesor
2013-02-11 16:27     ` Jeff King
2013-02-11 18:17       ` Ethan Reesor
2013-02-12 11:28       ` Michael J Gruber
2013-02-12 20:42         ` Jeff King
2013-02-13  8:08           ` Michael J Gruber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130211164518.ad0a21aff672ad0e4f03a6bb@domain007.com \
    --to=kostix+git@007spb.ru \
    --cc=firelizzard@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).