35

I'm trying to clone a GitHub repository into the newest release of VSCode (1.3.0). Can this be done natively or do I need to add an extension or additional binary?

I've also searched for a blog article and coming up empty handed so any guidance would be appreciated

Paul

2
  • what's the problem in opening a the bash prompt and writing git clone yourrepo?
    – Jepessen
    Jul 12, 2016 at 10:58
  • That was plan b or c
    – Paul B
    Jul 13, 2016 at 20:00

5 Answers 5

62

Starting from the 1.8 (November) update of vscode you can now clone your Git repository from within the vscode.

You can execute it from the Command Palette. Press F1 (or ++P on Mac) and search for Git: Clone. Confirm the command and paste the repository url.

0
1

There are now two programmatic ways how to clone a repository. VS Code handles the vscode:// protocol now, so you could clone a repository by clicking on a link somewhere on a web page

For example, clicking on the following link invokes VS Code, lets you select a folder on your disk, fetches the code and finally suggests to open that location as a workspace.

vscode://vscode.git/clone?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvscode-extension-samples

Alternatively, if you are trying to trigger the cloning from an extension code, use the built-in VS Code command git.clone with the repo url as the only argument.

import { commands} from 'vscode';

commands.executeCommand("git.clone", "https://github.com/microsoft/vscode-extension-samples");

Both seem to do the same as the Git: Clone command mentioned by Jakub.

1

Even faster, with VSCode 1.58 (June 2021), for GitHub repositories with the "Open in Visual Studio Code" badge.
While the announcement was removed, it was replaced with Visual Studio Code for the Web.

The VSCode Web "Opening a project" section mentions:

You can navigate to a project repository directly from a URL, following the scheme: https://vscode.dev/SOURCE/ORG/REPO.
Using the VS Code repo as an example, this would look like: https://vscode.dev/github/microsoft/vscode.

And issue 128813 suggests:

I suggest we just use shields.io for this:

https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc

badge from shields

So the mardown would be:

[![Open in VS Code](https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc)](https://vscode.dev/SOURCE/ORG/REPO)

3
  • it's not clear how to add this badge, no snippet given
    – Suncatcher
    May 31, 2022 at 13:07
  • @Suncatcher Good point, thank you for the feedback. I have updated/rewritten the answer to describe how that feature evolved, and include the markdown snippet you would need.
    – VonC
    May 31, 2022 at 19:54
  • @Suncatcher I just updated my own project README to include such a badge. It does work (provided you allow vscode.dev to sign in to your GitHub account)
    – VonC
    Jun 1, 2022 at 6:01
0

If you by native means in the GUI of the application, the answer is no. Though there is an open issue regarding this on their Github repository https://github.com/Microsoft/vscode/issues/9085 it doesn't look like they have the interest to implement it.

Even so, you can of course still clone a repository in your Terminal of choice and then handle the rest of your git functionality through the editor when you're working with the project.

1
  • Thanks looks like the current situation is no native integration and do it outside the UI. Thanks for the answer
    – Paul B
    Jul 13, 2016 at 19:59
-1

I use github Desktop (https://desktop.github.com/) for both my github repos and gitlab repos

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.