git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Hartmann <richih.mailinglist@gmail.com>
To: Git List <git@vger.kernel.org>
Subject: Cloning into an existing, non-empty directory?
Date: Thu, 21 Apr 2011 23:27:15 +0200	[thread overview]
Message-ID: <BANLkTi=VwiqN99AMEJb6jb1uFya2Hipibw@mail.gmail.com> (raw)

Hi all,

I know that the manpage explicitly states that it's not possible to
clones into an existing, non-empty directory, but I wanted to see if
anyone is aware of a workaround or if I can convince people that is it
of use in specific circumstances.

Some of you will be keeping their RC files in git repo(s) which means
you are basically left with two options:

1) Use soft-/hardlinks
2) Change your working tree

I went for option two which looks like:

richih@roadwarrior ~/.config/vcsh/repo.d/mr.git % ls -a
.   branches        config       FETCH_HEAD  hooks  info  objects    packed-refs
..  COMMIT_EDITMSG  description  HEAD        index  logs  ORIG_HEAD  refs
richih@roadwarrior ~/.config/vcsh/repo.d/mr.git % cat config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	worktree = /home/richih/
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = <remote>
[branch "master"]
	remote = origin
	merge = refs/heads/master
richih@roadwarrior ~/.config/vcsh/repo.d/mr.git %

This works just fine as long as you're using

  git --work-tree=$HOME \
    --git-dir=$HOME/.config/vcsh/repo.d/mr.git \
    pull

or similar on an existing, manually mangled repo. 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.

Obviously, this would imply some sort of conflict handling during cloning.

Anyway, I would _really_ love to have a way to avoid all this manual
work and just clone into $HOME, telling git that it's OK and I know
what I am doing.


Thanks,
Richard

PS: In case you are interested in keeping your RC files (and the rest
of your life) in git, there's a vcs-home mailing list and #vcs-home on
irc.oftc.net.

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21 21:27 Richard Hartmann [this message]
2011-04-21 22:03 ` Cloning into an existing, non-empty directory? Jonathan Nieder
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='BANLkTi=VwiqN99AMEJb6jb1uFya2Hipibw@mail.gmail.com' \
    --to=richih.mailinglist@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).