FreeKB - Git git clone command (clone a repository)
Git - git clone command (clone a repository)

The git clone command clones a repository from the source Git repo (typically called "origin") to a directory on your PC. For example, the foo.git and bar.git repositories could be cloned.

 

This could be done via SSH, like this.

git clone ssh://git@example.com/path/to/foo.git

 

Or via HTTPS.

git clone https://www.example.com/foo.git

 

By default, the git clone command will clone the repository into your present working directory.  A target directory can be included, like this. Be aware that the target directory must not already exist, as the target directory will be created as part of the cloning.

git clone https://www.example.com/foo.git /path/to/directory

 

if the repository is empty, something like this should be displayed.

Initialized empty Git repository in /path/to/directory/.git/
warning: You appear to have cloned an empty repository.

 

If the clone is successful, something like this should be displayed.

Initialized empty Git repository in /path/to/directory/.git/
remote: Enumerating objects: 90, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 90 (delta 29), reused 0 (delta 0)
Receiving objects: 100% (90/90), 131.06 KiB, done.
Resolving deltas: 100% (29/29), done.

 

Likewise, the git remote command with the -v or --verbose flag can be used to display the URL of the source Git repo (typically called "origin"). Something like this should be displayed.

cd /path/to/directory
git remote --verbose
. . .
origin  ssh://git@example.com:7999/path/to/foo.git (fetch)
origin  ssh://git@example.com:7999/path/to/bar.git (push)

 

After cloning a repository, by default, you will have a branch called "master" on your PC.

 

The git branch command with the --all flag can be used to show the branches.

git branch --all

 

Which will return something like this. The wildcard character is used to identify the branch you are currently using (master in this example)

* master

 

 

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 4653e in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |