How to clone a GitHub repository using terminal

 


For the past few months, I've been working on my first website from scratch! Since I often work on different devices, I had to clone my GitHub repository many times so that I could edit the code. To make my life easier, I learned a few shortcuts. One was to clone a GitHub repo using a terminal. I found this more straightforward and extremely helpful. So, here are some basic instructions for those who haven't tried it yet!

  1. Create a GitHub account at https://github.com/.

  2. Install VSCode. https://code.visualstudio.com/download

  3. Install the most recent version of Git. https://git-scm.com/downloads

  4. During installation, you will be asked to choose a credential helper. Select “Git Credential Manager Core.”

  5. Clone the repo

    1. Navigate to the main page of the repo you want to clone.

    2. Under the green dropdown “Code,” select the HTTPS tab and copy the link provided.

    3. Open your desktop files. Create a new directory (folder) somewhere you can find easily. Name the directory “GitHub/VSCode Projects” or similar.

    4. Clone the repo in a terminal.

      1. Open your terminal.

You will probably see something like this. (I use Windows Powershell, and my user is “ruoha”.)

  1. Navigate to your “GitHub/VSCode Projects” directory. For first-time terminal navigators, see this page for more information. (Note: For non-Windows users, please find instructions by searching “your-terminal-name” + “directory navigation”)

  1. Now, type “git clone” and a space.

  2. Paste the HTTPS link from the repo, and press “enter.”

  3. You’ll see the terminal say, “Cloning into ‘repo-name’...” and some statements with “done” at the end. This means a successful clone. (Note: The terminal might prompt you to sign in again to GitHub)

  4. If you encounter any error messages or unexpected statements, make sure you have followed all steps prior.

  1. Open the code.

    1. In the terminal, navigate to “VSCode Projects”.

    2. “cd” into the cloned repo directory.

    3. Now that you’re in the repo’s folder, type “code”, space, “.”

Wait a few seconds, and the code will open on VSCode.

Comments

Popular Posts