git clone named directory



~1 min read


159 words

Frequently, I find myself wanting to create a temporary clone of a repository. This often happens when something’s gone wrong and I want to isolate the issue with a fresh install.

My workflow for this used to include creating a new temporary directory and then cloning the project into the new folder.

The result was something like this:

$ pwd
$ mkdir temp
$ cd temp
$ git clone <repository>

It turns out that git clone actually facilitates this operation much more simply with an optional directory parameter.

$ git clone <repository> [<directory>]

The directory parameter works by allowing you to target a directory instead of taking the repository name as the title.

This might look like:

$ git clone
$ git clone clean-install-of-repository

The result is a cleaner file structure and a few saved keystrokes.

$ pwd
$ tree -L 1
├── original-repository
└── clean-install-of-repository

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!