git clone Command
git clone is a command used to clone a remote Git repository to the local machine.
git clone It can copy a remote Git repository to the local machine, allowing you to view the project or make modifications.
git clone command, you can copy all the code and history of the remote repository and create a local copy of the repository identical to the remote one.
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 on Github:
$
git clone
https:
//
github.com
/
tianqixin
/
runoob-git-test
Cloning into
'runoob-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 performing the above steps, Git clones the remote repository locally and creates a folder in the current directory with the same name as the remote repository (for example, the runoob-git-test folder in the above example).
After the above command completes, a runoob-git-test directory will be generated in the current directory:
$ cd simplegit/
$ ls
README.md runoob-test.txt test.txt
The above operation will copy all records of the project.
$ ls -a
. .. .git README.md runoob-test.txt test.txt
$ cd .git
$ ls
HEAD description index logs packed-refs
config hooks info objects refs
git clone The command automatically copies all branches and history records of the remote repository to the local machine, and you can use other Git commands (such as git checkout, git pull, etc.) to operate on the local repository.
By default, Git creates your local project directory based on the name of the project pointed to by the URL you provide. Usually it is the project name after the last / in the URL. If you want a different name, you can add the name you want after the command.
For example, the following example copies a remote git project, with the local project named another-runoob-name:
$
git clone
https:
//
github.com
/
tianqixin
/
runoob-git-test another-runoob-name
Cloning into
'another-runoob-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