Skip to content

A VCS extension that opens a local file under Git version control in its remote host using the default browser.

License

Notifications You must be signed in to change notification settings

alanhe421/vsc-extension-gitlink

Repository files navigation

GitLink - VS Code Extension

A VS Code extension that allows you to open the web version of files in your Git repository.

Visual Studio Marketplace Downloads

Visual Studio Marketplace Version

Visual Studio Marketplace Installs

Localization Status

Note for JetBrains IDE users: If you're using IntelliJ IDEA, WebStorm, or other JetBrains IDEs, we recommend using GitLink by Ben Gibson which provides similar functionality for JetBrains platforms.

screenshot1.gif 2025-03-02-110100.jpeg

Features

  • Right-click on a file in the editor and select "Open in GitHub" to open the file in your browser.
  • Right-click on a file in the editor and select "Copy GitHub Link" to copy the link to your clipboard.
  • Right-click on a file in the explorer and select "Open in GitHub" to open the file in your browser.
  • Right-click on a file in the explorer and select "Copy GitHub Link" to copy the link to your clipboard.
  • Right-click on a file in the explorer and select "Copy GitHub Markdown" to copy the markdown link to your clipboard.
  • Right-click on a file in the explorer and select "Copy GitHub Markdown Snippet" to copy the markdown snippet to your clipboard.
  • Right-click on a file in the explorer and select "Create GitHub Snippet Image" to open ray.so and create a Code Snippet Image.
  • Support multi-file copy in explorer.
  • Supports both SSH and HTTPS remote URL formats.
  • Automatically detects if the project uses a supported Git hosting platform when loading, and prompts the user if not.
  • Supports custom Git hosting platforms and URL templates.
  • Support pen tool to draw annotations on code snippet images. Double-click to clear drawings.

Built-in Supported Platforms

You can also add your own platform by configuring the gitlink.platforms and gitlink.domainRegistry settings.

Extension Settings

This extension provides the following settings:

  • gitlink.platforms: Custom Git hosting platform configuration, with the following fields:

    • name: Platform name (user-defined)
    • urlTemplate: URL template, supporting the following variables:
      • {repo:path}: Repository path (e.g., username/repo)
      • {branch}: Current branch name
      • {file:path}: Relative file path
      • {file:name}: File name
      • {file:dir}: File directory path
      • {remote:url}: Remote repository domain (e.g., github.com)
      • {remote:url:path:n}: The nth segment of the remote URL path (index starts from 0) (e.g., for git@github.com:alanhe421/alfred-workflows.git, {remote:url:path:0} is alanhe421, {remote:url:path:1} is alfred-workflows)
      • {line:start}: Line number (e.g., 1)
      • {line:end}: Line number (e.g., 10)
  • gitlink.domainRegistry: Domain-to-platform mapping configuration, with the following fields:

    • domain: Domain (e.g., github.com, gitlab.com)
    • platform: Platform name, must match a platform name defined in gitlink.platforms
  • gitlink.menuLevel: Context menu level for GitLink commands.

  • gitlink.rememberRemoteSelection: Whether to remember the remote selection for the cumenurent session. When enabled, the extension will remember yoursubmenue selection for the current session. You'll only be prompt is false.

  • gitlink.useRemoteForCodeImage: Whether to use remote service for code snippet images. When enabled, the extension will use the remote service - ray.so to create code snippet images. When disabled, the extension will use the local service to create code snippet images. Default is false.

Internationalization

GitLink supports multiple languages:

  • English
  • 简体中文 (Simplified Chinese)

The extension automatically detects your VS Code language setting and displays the interface in the appropriate language.

Sponsor

Buy Me A Coffee

Known Issues

  • If the project is not using a supported Git hosting platform, the extension will prompt the user when loading and provide an option to open settings

Enjoy!