Your public key has been correctly generated. SHA256:Lu0CV79iccFGzDLs4圆RXZbUOyimXRsIlNc0o30T+u4 Your public key has been saved in repo_id_rsa.pub. Your identification has been saved in repo_id_rsa. $ cd ~/.ssh & ssh-keygen -t rsa -b 4096 -C " "Įnter file in which to save the key (/home/schkn/.ssh/id_rsa):Įnter passphrase (empty for no passphrase): ssh” directory and create a new SSH key named “repo_id_rsa” where repo stands for the name of the repository you are trying to clone. In order to clone from a private repository using SSH, your SSH keys need to be correctly set and configured on your server.
In most of the cases, you want to secure your Git repositories with SSH keys in order to avoid having to type your password every single time. In this section, we are going to see how you can authenticate to your Git server using both methods. When cloning a Git repository, there are two ways of authenticating with the server : with a user/password set or using SSH keys. However, in some cases, you may have private Git servers that only authorized team members can access. It means that you did not need to provide any username or password in order to clone the repositories.
In the previous sections, we saw the various ways to clone public repositories to your local server. This option works for Git versions greater than 1.17.10, so make sure that this is the case before issuing the command. Make sure that only the branch chosen was fetched on your local repository. In order to clone and fetch exclusively the branch you chose, you have to specify the “–single-branch” option. Remotes/origin/feature Git clone exclusively one branch Note : you have to execute this command into the Git repository you just cloned. It means that if you run “git branch” with the “-a” (for all) option, you are going to see that all your branches were fetched.
Using the “-b” option, you are fetching all the branches but you are checking out the branch you chose. To verify that you correctly cloned the “dev” branch, make sure to run the “git branch” command. $ git clone -b įor example, in order to clone the “ dev” branch of your Github repository, you would run $ git clone -b dev In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. Your team may have chosen to let the “master” branch a bit behind and to have the most recent commits directly to the “dev” branch for example. However, in some cases, you may want to clone a specific branch in order to start working. You can check the current branch cloned by running the “git branch” command. In this case, you cloned the master branch from your Git remote repository. You successfully cloned a Git repository into a specific folder on your server. $ ls -lĭrwxrwxr-x 5 schkn schkn 4096 Nov 1 10:39 myproject Now, verify that you git project was correctly cloned to the destination folder. $ git clone įor example, given the Github project we fetched in the previous section, if we want to clone it into a folder named “myproject” we would run $ git clone myproject In order to clone a git repository into a specific folder, execute the “git clone” command and specify the destination folder at the end. Clone a Git repository into a specific folder However, you can choose to clone your Git repository into a different folder.
Receiving objects: 100% (813/813), 3.66 MiB | 5.52 MiB/s, done.Īs you can see, by default, Git is going to clone your Git repository into a folder named by the name of project. Remote: Total 813 (delta 0), reused 0 (delta 0), pack-reused 813 $ git clone įor example, let’s say that you want to clone a public repository from Github, you are going to execute the following command $ git clone To clone a git repository, use the “git clone” command with the URL of your Git repository. If Git is correctly installed, you are ready to start cloning your first Git repository.
To check if Git is correctly installed on Windows or on Linux, you need to execute the following command $ git -version In order to clone a git repository, you obviously need to have Git installed on your computer.