This guide will discuss the following methods:
So, let’s start!
How to Git SSH Works?
The user’s local machine can utilize the SSH agents to communicate with an SSH server instead of using the local machine as the SSH client.
How to Clone Git Remote Repository With SSH URL?
To clone the Git remote repository with the SSH URL, first, open up the GitHub hosting service, go to the desired remote repository and copy the SSH URL. Then, launch the Git terminal and move to the local repository. After that, run the “$ git clone” command with the SSH URL and clone it.
Now, implement the above-discussed instructions!
Step 1: Copy SSH URL
First, open up GitHub hosting service, go to the remote repository, hit the below-highlighted button, and copy the repository SSH URL:
Step 2: Move to Git Repository
Run the “cd” command and navigate to the existing Git local repository:
Step 3: Clone Repository With SSH URL
Now, clone the remote repository using the “git clone” command along with copied SSH URL:
It can be observed that the remote repository is cloned successfully:
Now, move ahead and learn how to clone specific branches with SSH URL.
How to Clone Git Remote Branch With SSH URL?
Like the whole repository, Git users can clone the specific remote branch with the SSH URL. To do so, follow the below steps.
Step 1: Clone Specific Branch
Execute the below-provided command with the “–branch” option to clone the specific branch:
Step 2: List Remote URLs
Check the list of remote URLs through the “git remote” command with the “-v” option:
According to the below output, the remote URL list is empty:
Step 3: Add Remote URL
Now, execute the “git remote add dev” command with SSH URL:
Step 4: Verify Remote URL
Run the “git remote” command with the “-v” option to verify if the remote URL has been added:
It can be observed that we have successfully cloned the remote branch:
We have provided the easiest method to clone the Git remote repository and specific remote branch with the SSH URL.
Conclusion
To clone the Git remote repository with the SSH URL, first, open up the GitHub hosting service, go to the desired remote repository and copy the SSH URL. Then, launch the Git terminal and move to the local repository. After that, clone the remote repository with SSH URL using the “$ git clone” command. However, to clone a specific remote branch, execute the “$ git clone –branch <ssh-url>” command. This guide illustrated the procedure to clone the Git remote repository and specific remote branch with the SSH URL.