Git Commands

An overview of the most important Git commands

git clone

The "clone" command downloads an existing Git repository to your local computer.

You will then have a full-blown, local version of that Git repo and can start working on the project.

Typically, the "original" repository is located on a remote server, often from a service like GitHub, Bitbucket, or GitLab). That remote repository's URL is then later referred to as the "origin".

Important Options

<repository>

Specifies the URL of the remote repository. Usually, this will point to a remote server, using a protocol like HTTP, HTTPS, SSH, or GIT.

<directory>

The name of the folder on your local machine where the repository will be downloaded into. If this option is not specified, Git will simply create a new folder named after the remote repository.

--recurse-submodules

Clones and initializes all contained submodules. If your project contains submodules, using this parameter will make sure that all submodules will both be cloned and initialized once the main project has been cloned. This saves you from having to manually initialize and update the submodules later.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Usage Examples

In its simplest (and most common) form, only the repository URL is specified:

cd folder/to/clone-into/
git clone https://github.com/gittower/git-crash-course.git

This will download the project to a folder named after the Git repository ("git-crash-course" in this case). If you want a different folder name, simply specify it as the last parameter:

git clone https://github.com/gittower/git-crash-course.git other-name

Tip

Simple Cloning in Tower

In case you are using the Tower Git client, cloning a project becomes easy as pie. You can connect your GitHub / GitLab / Bitbucket / or other remote accounts with Tower - and from then on simply clone with a single click!


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.