Install GitHub Desktop
GitHub Desktop helps the git user to perform the git-related tasks graphically. You can easily download the latest installer of this application for Ubuntu from github.com. You have to install and configure this application after download to use it. You can also check the tutorial for installing GitHub Desktop on Ubuntu to know the installation process properly.
Create a GitHub account
You will require a GitHub account to check the commands used in this tutorial for the remote repository.
Create a local and remote repository
You have to create a local repository and a remote repository to check the commands used for cloning.
Clone a remote repository:
Open the terminal and run the following `cd` command to go to the folder, git-repositories where the new local repository will be created. `git clone` command will make a copy of the remote repository named Django to the local folder. You have to provide your username and password of the GitHub account after running the `git clone` command. `ls` command will display the content of the current folder.
$ git clone https://github.com/fyc21/Django
The following output shows that the Django folder is copied from the remote server to the local folder.
Run the following commands to check the content of the Django folder.
The output shows that the Django folder has three folders, Models, Templates, and Views.
The content of the remote repository can be checked by opening the remote repository from github.com. https://github.com/fyc21/Django
The following output shows that the remote repository contains the same content that is downloaded in the local repository.
Clone a remote repository with a different name:
The clone command for copying the remote repository to a local repository with that same name has been shown in the previous example. The use of the clone command to create a local repository from a remote repository with a different name has shown in this part of this tutorial. Run the following command to create a local repository with the named django-tutorials by cloning the remote repository named Django.
The following output shows that a local repository named django-tutorials is created from the remote repository named Django.
Clone a remote repository using GitHub Desktop:
Open the GitHub Desktop and click on the option, “Clone a repository from the Internet…” to select the remote repository you want to copy in the local system.
The following dialog box will appear to select the remote repository. The list of published remote repositories is displaying here. Select the repository named bash, choose the local path where the repository will be stored in the local drive, and click on the Clone button to copy the repository.
The following content will be displayed after completing the cloning process. This repository contains only one file copied in the local repository, and the last commit message is “Bash tutorials“.
The remote repository has been copied properly or not into the local repository can be checked by executing the following code from the terminal. The first `ls` command will show the list of files and folder of the current location. `cd` command will change the directory location to the folder, bash that is the local repository folder copied from the remote repository. The first `ls` command will show the list of files and folder of the local repository, bash.
$ cd bash
The following output shows that the remote repository is copied properly in the defined folder of the local drive, and the folder contains the file named bash-basic-tutorial.sh of the remote repository.
Clone a local repository:
The `git clone` command can create a new local repository by copying an existing local repository. The first `ls` command will display the list of files and folders before executing the clone command. The clone command will create a new repository named bash-tutorial by copying the local repository named bash. The last `ls` command will display the list of files and folders after executing the clone command.
$ git clone bash bash-tutorial
The following output shows that the new local repository has been created after executing the above commands. Here, bash-tutorial is the newly created local repository.
Different uses of the clone command have been shown in this tutorial by using multiple demo git repositories. The ways of cloning remote repository have been explained here by using terminal and GitHub Desktop. The way of cloning the local repository has been shown by executing the git command from the terminal. I hope that the readers will be able to properly clone any local or remote repository after reading this tutorial.