• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    TypeScript
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Github Explorer made millions of github repos accessible right in vscode.

Remote - Github

vscode-zhihu logo

Browse Github Repositories Instantly Without Cloning

Why Remote - Github

How to browse github repository in VSCode?

Usually we need to git clone the whole git repo to our local file systems, even if we only want source code, or even a single subfolder.

That's really a waste of time and resource, especially when network is slow and the repo contains so many git big binary objects.

Remote - Github made opening a remote github repo as easy as open a local folder, you don't have to download anything to your local file system.

How to use Remote - Github

Using Remote - Github cannot be easier, all you need is to sign in, and browse.

Authentication

Invoke command Remote - Github: Sign In through command palette, type in your github username first:

Image

To authenticate yourself, you have two choice: Password Authetication and Personal Access Token.

How to get github Personal Acces Token

In the second popup window, type in your password or personal access token:

Image

After login success, you would see a cute github icon with your username on the right bottom bar:

Image

Provide your own keystore path

If you want higher security level, you could provide your own path of file which contains your authentication string in <username>:<password> or <username>:<personal access token>. For example:

Image

And paste absolute path to Remote - Github: Keystore Path in VSCode Settings UI:

Image

You must sign in to get more request times to api.github.com per hour. According to github official doc, authenticated user can make up to 5000 core requests to api.github.com every hour. Anonymous user could only make 60 requests per hour.

Setup Github To Workspace

Invoke Remote - Github: Setup Workspace to mount github folder to your workspace, after which you would see a folder named Github appeared in your workspace:

Image

Open Repository

Invoke Remote - Github: Open Github Repository, you would see this popup:

Image

Just type in the url of your github repository, for example, https://github.com/golang/go, or just repo path: golang/go, and hit enter:

Image

you can navigate through this repository just like navigate your local folder, .. gets you to the parent folder, select . would open current folder. If you select a file, you would just open this file.

Let's try to navigate through golang/go repository:

Image

Of course you can open the whole repository, all you need is select "." in the first entry, and the repository would appear magically in your Github Folder:

Image

Note that the folder resides in memory, not stored persistently, if you close the window, all loaded files are gone.

Many times, a git repository contains many independent tutorial samples, typically microsoft/vscode-extension-samples, so you could open only the sample you want:

Image

Instead of cloning the whole big git repository, you could just open one subfolder:

Image

Open one file is also ok. You can try it out.

Enable VS Code Full Feature Set By Providing Mount Point

VS Code supports Intellisense, Code Navigation, File Searching, etc. Browing code would be much easier with these amazing features, but people find they cannot do this with files loaded by Remote - Github.

It is because Remote - Github stores them to memory, namely, virtual file system first, so the vscode could not analyze it, neither do other tools like npm, maven, etc.

Remote - Github now gives you a choice to enable all these features by writing loaded files to your local fs. It's really simple, all you need is provide a "mount point" (just an absolute path to store the whole github folder):

Image

Once the mount point is provided, all loaded file would be written to a newly created github folder under your mount point, and everything works just like before except that vscode features are enabled.

After that, you could find anything in your local github folder, and you can compile it, modify and save it, and run it.

Repository Searching

In 0.1, if you want to open vscode repo, you need to input https://github.com/microsoft/vscode. To do this, you have to open github and find this repo, paste link to Remote-Github.

With Repository Searching, all you have to do it provide a single keyword like "vscode", and Remote-Github would provide you several searching results for you to pick:

Image

This would not break the old behavior, if you provide full link, everything works like in 0.1.

Namespaces

The namespaces of file are dealt with gracefully, open mutiple repos would not conflict with each other:

Image

It seems we mount the whole Github as our local disk partition!

Save As Local Files

Although the repo resides in memory, but you could download it to your local file system:

Image

Just right click any folder or files, and click download.

Open Different Snapshot

Remote - Github seems ignore the "git things": branches, commits, tags...

But it's not.

You can specify which branch, or which tag you want to browse, and the syntax is pretty straghtforward:

If you want to open dev.link branch of golang/go, just type in:

golang/go -b dev.link

Image

If you want to open v5.6 tag of torvalds/linux:

torvalds/linux -t v5.6

Create Remote Github Repository In VS Code

In order to set up a remote repo, usually we need to open browser and create a repo in github manually, and then push the local repo to it.

With Remote - Github, you can create remote github repo right in VS Code and sync with your local repo automatically.

Just invoke Remote - Github: Create Remote Github Repository command, and input the repo name and description:

Image

Image

select repo type, public or private:

Image

Wait a sec, the repo would be created:

Image

click see it to see the repo in browser:

Image

Once repo is created, Remote - Github would open a new terminal, and run several commands to set up your local repo to sync with your remote repo:

git init
git remote add origin https://github.com/<username>/<reponame>
git push -u origin master

Notice that git init would have no effect if your local repo has already set up git. Just don't worry it.

Limits

Open big repository like torvalds/linux, microsoft/vscode from root folder would cause some network & performance issue. The best practice is only open what you need, not whole repo.

Design Philosophy

  1. load only source code, not whole git history.
  2. load to memory first, not to local environment.
  3. open only what you need, not everything.
  4. download as you need.
  5. convention over configuration.

Configurations

Config Effect
Remote - Github: Max Request Times Per Open The max number of request time every repo opening. If set too large, nework & performance issues may occur.
Github: Use Sync Load Asynchronous https requesting would make repo loading faster, but prone to be detected as robot. Set this true makes loading synchronous, which would slower loading process, but makes it more robust to robot detection.
Remote - Github: Keystore Path Instead of type in username and authentication string manually, you can provide the absolute path of your own file which contains <username>:<password> or <username>:<private access token>.
Remote - Github: Mount Point If provided, dynamically loaded repo would be written to here. (Please provide absolute path)