10
$ git clone ssh://host/repo.git ~/
destination directory '/home/username/' already exists.

Can anyone tell me how to make this work? I'm trying to quickly be able to replicate common dev scripts and config.

T Zengerink
  • 3,983
  • 5
  • 27
  • 31
rich
  • 17,280
  • 9
  • 58
  • 96
  • 1
    `git clone` looks to either create a new directory under the working path, or at the path specified. Since `~/` already exists, it can't create a new dir... – Karl Barker Feb 25 '12 at 12:23
  • 1
    Do you actually want to pull your whole home directory from a git repo? Or into a subdirectory? – Kevin Hughes Feb 25 '12 at 12:24
  • 1
    Yes, all the files in the repo belong in the home directory. – rich Feb 25 '12 at 12:33

4 Answers4

33

This seems to work:

cd ~
git init
git remote add origin ssh://host/repo.git
git pull origin master
rich
  • 17,280
  • 9
  • 58
  • 96
2

The clone command creates a new directory when you pass a second argument:

$ git clone ssh://host/repo.git ~/your_directory

clone will create ~/your_directory. If the directory already exists it will give you the error you get.

ouah
  • 134,166
  • 14
  • 247
  • 314
  • @rich just give a directory name like in my example or do `cd ~ && git clone ssh://host/repo.git` – ouah Feb 25 '12 at 12:40
1
cd ~
git clone ssh://host/repo.git

After that, you have the project in the /home/username/repo/ directory

If you want to have the project in a different folder name (e.g 'foo/')

mkdir ~/foo
cd ~/foo
git clone ssh://host/repo.git foo/
Sandro Munda
  • 36,427
  • 21
  • 94
  • 117
0

I would clone the repository into a subdirectory:

git clone ssh://your/git/repo.git ~/repo

And create symlinks to the configuration files:

ln -s ~/repo/.bashrc ~/.bashrc
T Zengerink
  • 3,983
  • 5
  • 27
  • 31
  • 1
    That would be a nightmare to do for each and every file in the repo for every machine I want to clone it onto. – rich Feb 25 '12 at 12:33
  • 1
    Of course, but you create a shell script for that aswell.. [Github example](https://github.com/Mytho/dotfiles/blob/master/setup.sh) – T Zengerink Feb 25 '12 at 12:36