Getting Started Git Basics Clone

Clone

Learn what cloning does, what it copies, and how it differs from git init.

Cloning creates a new local copy of an existing Git repository, usually from a hosting service like GitHub or from another machine.

If someone else already created the repository, cloning is the usual way to get that project onto your own computer.

What cloning copies

When you clone a repository, Git creates a new local repository on your machine and copies the repository data it needs into that new folder.

That usually includes:

  • The current project files.
  • The commit history.
  • Branch and tag references.
  • A remote connection back to the source repository, usually named origin.

After cloning, you have your own local copy of the repository. You can inspect history, edit files, create branches, and make commits in that copy.

Why cloning is useful

Cloning is how you start working with an existing project.

For example, you clone when:

  • You want to contribute to a project hosted on GitHub or another Git server.
  • You want your own local copy of a repository that another teammate created.
  • You want to download a repository to inspect its code and history locally.

Once the repository has been cloned, GitComet can open that local copy and show its history, branches, changed files, and remotes.

Clone vs Init

Cloning and initializing both create a repository on your machine, but they are used for different starting points.

Use git clone when the repository already exists somewhere else and you want a copy of it locally.

Use git init when you are starting a brand new repository from an existing folder or creating a project that does not have Git history yet.

In short:

  • git clone copies an existing repository.
  • git init creates a new repository in place.

What happens after cloning

After you clone a repository, your local copy usually knows where it came from. That source repository is stored as a remote, often called origin.

That is what allows Git to later:

  • Fetch new changes from the original repository.
  • Push your own commits back to a repository you have permission to update.
  • Compare your local branches with remote branches.

Cloning gives you the starting copy. Fetching, pulling, and pushing are the commands used later to keep copies in sync.

HTTPS and SSH clone URLs

To clone a repository, Git needs the location of the source repository. That location is usually given as a URL.

Two common kinds of clone URLs are:

  • HTTPS, such as https://github.com/example/project.git
  • SSH, such as git@github.com:example/project.git

HTTPS is often simpler to start with, especially if you sign in through a browser or use a credential manager.

SSH is commonly used by developers who have set up SSH keys and want passwordless authenticated access from the command line.

Both point to the same repository. The difference is mainly how you connect and authenticate.

Documentation

Search

move open Esc close

Browse the docs or start typing to filter results.