Easy Tutorial
❮ Home Git Create Repository ❯

git clone Command

Git Basic Operations


git clone copies a Git repository to your local machine, allowing you to view the project or make modifications.

The command format for copying a project is as follows:

git clone [url]

[url] is the project you want to copy.

For example, we copy a project from Github:

$ git clone https://github.com/tianqixin/tutorialpro-git-test
Cloning into 'tutorialpro-git-test'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.

After cloning, a directory named tutorialpro-git-test is generated in the current directory:

$ cd simplegit/
$ ls
README.md    tutorialpro-test.txt    test.txt

This operation will copy the entire project history.

$ ls -a
.        ..        .git        README.md    tutorialpro-test.txt    test.txt
$ cd .git 
$ ls
HEAD        description    index        logs        packed-refs
config        hooks        info        objects        refs

By default, Git creates your local project directory with the name of the project as provided by the URL. Usually, this is the name after the last / in the URL. If you want a different name, you can specify it at the end of the command.

For example, the following command copies the remote Git project with a local project name another-tutorialpro-name:

$ git clone https://github.com/tianqixin/tutorialpro-git-test another-tutorialpro-name
Cloning into 'another-tutorialpro-name'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.

Git Basic Operations

❮ Home Git Create Repository ❯