How to Clone a Git Repository Content to a Given Folder

When you clone a Git repository with the git clone command like so:

The content of the repo will be downloaded or cloned into a WP_List_Table-Class-Plugin-Example (repository name) folder.

This might not be your expected behavior. An example of what your expection might be is for the content of the Git repository to be cloned into your current directory or to a named folder in the current directory.

To clone a git repo to your current directory, include . after the repo’s HTTPS or SSH address like so:

To clone to a folder called wordpress, use the command below:

You can also clone the repo content to a nested folder like so:

Note: the above commands requires that the folder (where the repository content will be downloaded to) must be empty.

If the folder isn’t empty, your last resort might be to initialize git in the folder, add the repo URL as origin and finally make a pull like so:

The above commands can be simplified to a git alias such that running
git cp https://github.com/collizo4sky/WP_List_Table-Class-Plugin-Example.git will perform the same task as the above commands.

To create a cp alias, add the line of code below to your .gitconfig file.

If you have git alias already, be sure to remove [alias] from the code above and only add the cp command to your existing alias.

La Fin!