Skip to contentSkip to conversation

Default Clone Dir?

DISCUSSION [email protected] 2 participants 3 messages Aug 4, 2019

lore
Share & tools
lore
#0 lore raw

hi,
Is there a way to set default clone destination directory on linux? Currently, seems to clone to the active dir.
-thx!

#1 lore raw
Quoted 3 lines · On 2019-08-04 at 17:13:36, [email protected] wrote:

hi,
Is there a way to set default clone destination directory on linux? Currently, seems to clone to the active dir.

It sounds like you want to always clone repositories to a single directory. git clone doesn't have a configuration setting to do that, but you can specify the directory you want to clone. For example:

git clone https://github.com/git/git.git

would create a directory "git" under the current directory, but you could also write the following:

git clone https://github.com/git/git.git ~/checkouts/git

to create the repository in ~/checkouts/git. You can also do this:

git -C ~/checkouts clone https://github.com/git/git.git

which will change to ~/checkouts and then perform the clone there. "-C" says to change directory to the given location before running the command; it must be specified before the "clone" command.

If you want to automate this, you can create an alias:

  git config --global alias.myclone '!f () { git -C ~/checkouts clone "$@"; };f'
  git myclone https://github.com/git/git.git

and then your alias will always clone to that directory.

Signature · 2 lines
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204