git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Default Clone Dir?

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 4, 2019, 17:20 UTC
Message-ID
<20190804172008.GG118825@genre.crustytoothpaste.net>
In-Reply-To
<1564938816.2622.1@gmail.com>
On 2019-08-04 at 17:13:36, johnywhy@gmail.com 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.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: johnywhy@gmail.comNext: johnywhy@gmail.com
Message 2 of 3 in “Default Clone Dir?”
  1. johnywhy@gmail.comAug 4, 2019
  2. brian m. carlsonAug 4, 2019
  3. johnywhy@gmail.comAug 4, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.