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

Re: Publishing Question: First time Pushing to nonexsiting directory

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 19, 2007, 08:10 UTC
Message-ID
<20070219081010.GC30030@spearce.org>
In-Reply-To
<20070219073526.GA26531@cip.informatik.uni-erlangen.de>
Thomas Glanzmann <thomas@glanzmann.de> wrote:
Show 16 quoted lines
> I thought that there is a command available which I can use to push a
> repository to a remote nonexisting location (that gets created on the
> fly) like in the following scenario:
> 
>         - Create a git project on my laptop
>         - Check in a few files
>         - Publish the git repository to 
> 
>         (thinkpad) [~/work/astro-tg] git push 131.188.30.59:/home/cip/adm/sithglan/work/repositories/private/astro/
>         fatal: '/home/cip/adm/sithglan/work/repositories/private/astro': unable to chdir or not a git archive
>         fatal: The remote end hung up unexpectedly
> 
> I thought that I read a comment from Linus(?) long time ago to how to obtain
> that. But I am unable to find the e-mail in my archives. If there is no
> standard way, how do you do it? Just rsync the files and change the
> 'origin'?

SSH into the remote system that you want to push to, then run init-db there:

  $ ssh 131.188.30.59 git --git-dir=/home/cip/adm/sithglan/work/repositories/private/astro.git init-db
Configure that as a remote, e.g. origin:
  $ git remote add origin 131.188.30.59:/home/cip/adm/sithglan/work/repositories/private/astro.git
Now push to there:
  $ git push origin master:master
And maybe fetch back to create the tracking branches:
  $ git fetch

Note that in my examples above I added ".git" to the end of the repository path, as this is rather typical for a 'bare repository' (that is, a repository without a working directory attached). You usually don't want to push into a repository with a working directory, but it is supported and a lot of folks do it.

I also assumed Git 1.5.0 on your thinkpad end, as git-remote was recently added in that version. Handy tool. :)

-- 
Shawn.
Previous: Thomas GlanzmannNext: Thomas Glanzmann
Message 2 of 6 in “Publishing Question: First time Pushing to nonexsiting directory”
  1. Thomas GlanzmannFeb 19, 2007
  2. Shawn O. PearceFeb 19, 2007
  3. Thomas GlanzmannFeb 19, 2007
  4. Shawn O. PearceFeb 19, 2007
  5. Thomas GlanzmannFeb 19, 2007
  6. Junio C HamanoFeb 19, 2007

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.