views:

49

answers:

1

Hi,
I often use git from Terminal on Mac to download some repositories and then use it.

When I use this command:

git clone git://git repository URL
repositories are downloaded in my Start folder (name account folder e.g. Matthew, if the name of my Mac account is Matthew).

I'd like to change this folder where repositories are downloaded.
How can I do this when I download a new repo?

Thanks,
Matthew

+3  A: 

Git places the cloned repository in a newly created directory in the path you are currently residing (check with pwd). If you cd to a different path, the directory will be placed there.

Alternatively, you can specify a directory as part of the git clone command. For example:

git clone git://<git repo url> /path/to/cloned/repo

See git help clone.

Greg Sexton
Also Use cdto http://code.google.com/p/cdto/ to open the target dir in Terminal from Finder. Then git clone as suggested.
ustun
I used this command: git clone git://<git repo url> ./Users/Matteo/Desktop... this work but the repo isn't downloaded in my Desktop folder but always in the start folder creating Users folder, with inside it Matteo folder, inside it Desktop folder and then the repo files...
Matthew
`./` means 'relative to the current directory', I think you mean `/Users/Matteo/Desktop`.
Greg Sexton
I now tried the directory without '.', only /Users/Matteo/Desktop but I receive a fatal error: destination path '/Users/Matteo/Desktop' already exists and is not an empty directory. How can I resolve this?
Matthew
@Matthew: create an empty subdirectory to `Desktop` and clone in it, or simply mention the destination directory (which doesn't exist yet and will be created): `git clone git://<git repo url> ./Users/Matteo/Desktop/myGitRepo`
VonC
Yes sorry, you need to specify a new folder that git will create and place the cloned repo in. `git clone git://<git repo url> /Users/Matteo/Desktop/clonedRepo` should work.
Greg Sexton
@Greg @VonC thanks, now it works :)
Matthew
@Matthew, apologies I just tested my own advice and realised I was wrong. Deleted the comment. See my last comment for the correction.
Greg Sexton
@Greg Oh I just read the new comment :) Thanks!
Matthew