Skip to content

Instantly share code, notes, and snippets.

@jamiehs
Created September 23, 2013 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiehs/6677047 to your computer and use it in GitHub Desktop.
Save jamiehs/6677047 to your computer and use it in GitHub Desktop.
Here's a little trick for cloning into an existing directory. The long and short of it is that you're checking the project out into a temp folder, then moving the git directory, and then resetting to the head.
# From: http://stackoverflow.com/a/2484349/24559
git clone --no-checkout repo-to-clone existing-dir/existing-dir.tmp
mv existing-dir/existing-dir.tmp/.git existing-dir/
rmdir existing-dir/existing-dir.tmp
cd existing-dir
git reset --hard HEAD # git thinks all files are deleted, this reverses that behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment