git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Richard Hartmann <richih.mailinglist@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: Cloning into an existing, non-empty directory?
Date: Thu, 21 Apr 2011 17:03:27 -0500	[thread overview]
Message-ID: <20110421220327.GA3396@elie> (raw)
In-Reply-To: <BANLkTi=VwiqN99AMEJb6jb1uFya2Hipibw@mail.gmail.com>

Hi,

Richard Hartmann wrote:

> The only real
> problem left is that I can't clone initially as $HOME is obviously
> non-empty, resulting in
>
>   git --work-tree=$HOME \
>     --git-dir=$HOME/.config/vcsh/repo.d/mr.git \
>     clone <remote> .config/vcsh/repo.d/mr.git
> fatal: working tree '/home/richih' already exists.
>
> This means I am down to cloning, creating the directories I need,
> moving .git and the actual files around, making git aware that tracked
> files were not deleted, just moved, and then finally being able to use
> my repo.

Have you tried something like the following?

	cd $CROWDED_DIRECTORY
	GIT_DIR=/path/to/git/dir
	GIT_WORK_TREE=$(pwd)
	export GIT_DIR GIT_WORK_TREE

	git init
	git remote add origin <remote>
	git pull

Two more caveats for the road. :)

 - git does not track detailed file permissions or secret/non-secret
   status.  Please be careful about ssh private keys and so on.

 - when updating the worktree, git will unlink existing files before
   replacing them and does not fsync the result.  So one should be
   careful when tracking files that will cause major harm if they go
   missing temporarily (though I can't think of any major examples in
   $HOME offhand).

Happy hacking,
Jonathan

  reply	other threads:[~2011-04-21 22:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21 21:27 Cloning into an existing, non-empty directory? Richard Hartmann
2011-04-21 22:03 ` Jonathan Nieder [this message]
2011-04-22 11:21   ` Richard Hartmann
2011-04-23 10:15     ` Jonathan Nieder
2011-04-23 10:28       ` Nguyen Thai Ngoc Duy
2011-04-23 10:37         ` Jonathan Nieder
2011-04-23 22:11       ` Richard Hartmann
2011-04-25  8:00         ` Jonathan Nieder
2011-04-25  8:40           ` Andreas Schwab
2011-04-25  8:59             ` Jonathan Nieder
2011-04-25 18:37               ` Jeff King
2011-04-25 14:08           ` Richard Hartmann

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=20110421220327.GA3396@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=richih.mailinglist@gmail.com \
    /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).