I came across git clone /path/to/repository
in my Git tutorial. What does this command do and when will you use it?
When there exists a repository at /path/to/repository
, or in Windows-speak, C:\path\to\repository
, then the commands
git clone /path/to/repository # Linux, Unix, Cygwin
git clone C:\path\to\repository # Windows CMD
git clone C:/path/to/repository # Git-for-Windows's shell
create a copy of the repository in the new directory repository
(in the current directory where you issued the git
command). This copy treats the original at /path/to/repository
as the "origin" repository, from which you can pull changes and to which you can push changes.
It is the same as if you had cloned a repository from some remote hosting site; it just so happens that the origin is located on your local disk.