threads / discuss / 58158

Create Remote Repository from local

Subject: Create Remote Repository from local

## tl;dr

2 messages between Jul 14, 2022 and Jul 14, 2022.

replies: 1people: 2as markdown or json

Antonio Cabañas Zurita· Jul 14, 2022, 09:50 UTC · lore
Hi,
I'm setting up a git server, but I've run into a little problem.

It is possible to generate a remote repository on the server from a local repository, or for this it must be created on the remote (server), regardless of whether it is by cloning or by remote add.

Assuming that I am in a newly created local repository I have tried:
Do a git remote add ssh://git@git/<location>

And I have not previously created a repository in location(on the server side), it returns an error that it is not a known repository in the destination.

I do not know if I explained well.
Thank you for your your time,
Cheers
Ævar Arnfjörð Bjarmason· Jul 14, 2022, 10:11 UTC · re: Antonio Cabañas Zurita · lore

Re: Create Remote Repository from local

On Thu, Jul 14 2022, Antonio Cabañas Zurita wrote:
Show 15 quoted lines
> Hi,
>
> I'm setting up a git server, but I've run into a little problem.
>
> It is possible to generate a remote repository on the server from a
> local repository, or for this it must be created on the remote
> (server), regardless of whether it is by cloning or by remote add.
>
> Assuming that I am in a newly created local repository I have tried:
>
> Do a git remote add ssh://git@git/<location>
>
> And I have not previously created a repository in location(on the
> server side), it returns an error that it is not a known repository in
> the destination.

The default local git client + server setup does not automatically create repos on the remote, do you mean that you'd like to "git init" locally, then just have a "git remote add" on your own server create it?

That *is* possible, and I've worked with a server seup like that, it just used a git-shell(1) replacement to intercept the "git upload-pack" command, i.e. you'll get a /path/to/repo.git" argument, which you can just intercept and "git init" that repo on the server, then serve the normal "git-upload-pack" on that newly created repo.

Using that method you can:
	# locally
	git init r &&
	echo hi >r/file &&
	git -C r add file &&
	git -C r commit file &&
	git -C r push <some server url> master:master
Or whatever, and have it work.

But I don't know (and didn't test) how that works with "git remote add", i.e. if the remote addition will expect a remote branch in some sensble state on the remote.

So I could see how you'd get into a chicken & egg problem there, i.e. you'd want to find the remote state, but your repo hasn't been created yet...

← back to recent threads