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.
Using Remote - Github cannot be easier, all you need is to sign in, and browse.
Invoke command Remote - Github: Sign In through command palette, type in your github username first:
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:
After login success, you would see a cute github icon with your username on the right bottom bar:
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:
And paste absolute path to Remote - Github: Keystore Path in VSCode Settings UI:
You must sign in to get more request times to
api.github.comper hour. According to github official doc, authenticated user can make up to 5000 core requests toapi.github.comevery hour. Anonymous user could only make 60 requests per hour.
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:
Invoke Remote - Github: Open Github Repository, you would see this popup:
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:
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:
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:
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:
Instead of cloning the whole big git repository, you could just open one subfolder:
Open one file is also ok. You can try it out.
The namespaces of file are dealt with gracefully, open mutiple repos would not conflict with each other:
It seems we mount the whole Github as our local disk partition!
Although the repo resides in memory, but you could download it to your local file system:
Just right click any folder or files, and click download.
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
If you want to open v5.6 tag of torvalds/linux:
torvalds/linux -t v5.6
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.
- load only source code, not whole git history.
- load to memory first, not to local environment.
- open only what you need, not everything.
- download as you need.
- convention over configuration.
| 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>. |















