How to Clone a Repository on GitHub

Table of contents:

How to Clone a Repository on GitHub
How to Clone a Repository on GitHub

Video: How to Clone a Repository on GitHub

Video: How to Clone a Repository on GitHub
Video: How to animate profile picture/ banner on discord mobile (Must have nitro obviously) 2024, November
Anonim

Git is a very common tool in collaborative software development. Local-level repository cloning stores the latest changes to the project so you can work independently and make your own edits without directly affecting the work of others. To clone a repository, you will need to download Git or Git-supported software, locate the repository you want to clone, and specify where to save the cloned repository. You can do this through a command line program or a graphical user interface (GUI) supported program.

Step

Method 1 of 3: Using the Command Line

Clone a Repository on Github Step 1
Clone a Repository on Github Step 1

Step 1. Download and install Git

Visit https://git-scm.com/downloads and select the download according to the platform you are using.

Clone a Repository on Github Step 2
Clone a Repository on Github Step 2

Step 2. Create the repository directory

Go to the desired directory on your computer. Right-click (or Ctrl+click) an empty space in the directory and select “New Folder”.

To make it easy, it's a good idea to create a repository first on the desktop

Clone a Repository on Github Step 3
Clone a Repository on Github Step 3

Step 3. Open Git CMD

This program comes preinstalled with Git tools. However, you can also use the built-in Command Prompt (Windows) or Terminal (Mac/Linux) program.

Clone a Repository on Github Step 4
Clone a Repository on Github Step 4

Step 4. Visit the target directory via command line

Enter the command "cd", followed by the address of the repository folder that has been created. The folders in the address are separated by a “\” sign. Press Enter to complete the action.

  • For example, if you create a folder on the desktop on a Windows computer, use the command “cd c:\users\[username]\desktop\[foldername]”
  • “cd” stands for “change directory” (change directory).
  • Instead of all at once, you can change directories one by one if you find it easier to type: “cd desktop” Enter “cd folder name” Enter.
Clone a Repository on Github Step 5
Clone a Repository on Github Step 5

Step 5. Visit the repository page in a web browser

Access the GitHub repository page (or alternative Git page) that you want to clone. The repository source location is shown on the repository page.

The exact position of the source location will depend on the repository in use, but is usually shown at the top of the page for easy access. Try looking for the repository URL on the page

Clone a Repository on Github Step 6
Clone a Repository on Github Step 6

Step 6. Copy the source location

Click the source location (usually a URL starting with “https” or “ssh”) and press the shortcut Ctrl+C or Cmd+C to copy it.

Clone a Repository on Github Step 7
Clone a Repository on Github Step 7

Step 7. Enter “git clone”, followed by the source location into the command line program

The “git” command tells the command line program that you are using a Git function, and the “clone” command instructs the program to clone the location entered after the command. Paste or type the source location after the command.

To paste a URL or location into the Windows Command Prompt, you need to right-click the program window and select “Paste” from the context menu. However, it is not necessary to follow these steps in Terminal on a Mac or Linux computer

Clone a Repository on Github Step 8
Clone a Repository on Github Step 8

Step 8. Press Enter key

The cloning process will start and the progress of the process will be displayed on the command line. You will get a notification when the process is complete via a message in the Command Prompt window.

Method 2 of 3: Using the Git GUI

Clone a Repository on Github Step 9
Clone a Repository on Github Step 9

Step 1. Download and install Git

Visit https://git-scm.com/downloads and select the download according to the platform you are using.

Clone a Repository on Github Step 10
Clone a Repository on Github Step 10

Step 2. Create the repository directory

Go to the desired directory on your computer. Right-click (or Ctrl+click) an empty space in the directory and select “New Folder”.

To make it easy, it's a good idea to create a repository first on the desktop

Clone a Repository on Github Step 11
Clone a Repository on Github Step 11

Step 3. Visit the repository page in a web browser

Access the page of the GitHub repository (or any Git product) you want to clone. The repository source location is shown on the repository page.

The exact position of the source location will depend on the repository in use, but is usually shown at the top of the page for easy access. Try looking for the repository URL on the page

Clone a Repository on Github Step 12
Clone a Repository on Github Step 12

Step 4. Copy the source location

Click the source location (usually a URL starting with “https” or “ssh”) and press the shortcut Ctrl+C or Cmd+C to copy it.

Clone a Repository on Github Step 13
Clone a Repository on Github Step 13

Step 5. Open the Git GUI

This program is installed alongside other Git tools. Instead of a command line (text) window, you'll see a window with several clickable buttons.

Clone a Repository on Github Step 14
Clone a Repository on Github Step 14

Step 6. Click “Clone Repository”

This option is the first choice on the boot splash page.

You can also select “Clone” from the “Repository” drop-down menu

Clone a Repository on Github Step 15
Clone a Repository on Github Step 15

Step 7. Enter the source location

Paste or type the repository source location in the field provided.

Clone a Repository on Github Step 16
Clone a Repository on Github Step 16

Step 8. Enter the target directory

Type in the address of the repository folder you created.

You can also click “Browse” to browse for a folder without having to type it in

Clone a Repository on Github Step 17
Clone a Repository on Github Step 17

Step 9. Click “Clone”

A GUI window will display the progress of the process and notify you once the cloning process is complete.

Method 3 of 3: Using Visual Studio

Clone a Repository on Github Step 18
Clone a Repository on Github Step 18

Step 1. Visit the repository page via a web browser

Access the page of the GitHub repository (or other GitHub product) you want to clone. The repository source location is shown at the top of the page.

The exact position of the source location will depend on the repository in use, but is usually shown at the top of the page for easy access. Try looking for the repository URL on the page

Clone a Repository on Github Step 19
Clone a Repository on Github Step 19

Step 2. Copy the source location

Click the source location (usually a URL starting with “https” or “ssh”) and press the shortcut Ctrl+C or Cmd+C to copy it.

Clone a Repository on Github Step 20
Clone a Repository on Github Step 20

Step 3. Open Visual Studio

Visual Studio is a fairly common program in the Windows development environment, but it's not free to use. You can download VS Express to get the free edition (with limited features).

Clone a Repository on Github Step 21
Clone a Repository on Github Step 21

Step 4. Select the “Team Explorer” tab

This tab is at the bottom of the right sidebar.

Clone a Repository on Github Step 22
Clone a Repository on Github Step 22

Step 5. Click the “Manage Connections” button

This button is indicated by the plug icon and is in the top menu bar in the right sidebar.

Clone a Repository on Github Step 23
Clone a Repository on Github Step 23

Step 6. Click “Clone”

It's in the “Local git repositories” section in the right sidebar.

Clone a Repository on Github Step 24
Clone a Repository on Github Step 24

Step 7. Enter or paste the source location into the text field

Once added to the column, the “Clone” action button can be clicked.

Clone a Repository on Github Step 25
Clone a Repository on Github Step 25

Step 8. Click “Clone”

It's below the source location field. Once clicked, a progress bar will be displayed showing the cloning process. The process is complete once the bar is fully charged.

The cloned repository is automatically cloned to a local directory in the Visual Studio directory

Tips

  • Use git pull to update the repository, instead of re-cloning. Perform re-cloning in certain situations (eg when you have fatal merge or compilation problems).
  • To clone his git clone remotely, use the format “username@host:/address/to/repository” after “git clone”.
  • If you move the repository directory, make sure you make the proper adjustments when trying to access it again via the command line.

Recommended: