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
Step 1. Download and install Git
Visit https://git-scm.com/downloads and select the download according to the platform you are using.
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
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.
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.
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
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.
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
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
Step 1. Download and install Git
Visit https://git-scm.com/downloads and select the download according to the platform you are using.
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
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
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.
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.
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
Step 7. Enter the source location
Paste or type the repository source location in the field provided.
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
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
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
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.
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).
Step 4. Select the “Team Explorer” tab
This tab is at the bottom of the right sidebar.
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.
Step 6. Click “Clone”
It's in the “Local git repositories” section in the right sidebar.
Step 7. Enter or paste the source location into the text field
Once added to the column, the “Clone” action button can be clicked.
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.