Edamagit:VS Code 的 Magit
Edamagit: Magit for VSCode

原始链接: https://github.com/kahole/edamagit

Edamagit 是一个 VSCode 扩展,它将 Magit 强大的、基于键盘驱动的 Git 体验带到了 VSCode。它提供用于状态查看、文件操作、派发命令以及通过弹出窗口提供帮助的命令。主要功能包括暂存、取消暂存、丢弃更改、分支、提交、合并、变基等等,所有这些都可以通过直观的键盘快捷键访问。Forge 集成支持拉取请求和问题。自定义选项包括窗口位置和隐藏状态部分。通过自动检测 .git 目录来支持单仓管理。该扩展高度可定制,所有按键绑定都可以通过 VSCode 的 `keybindings.json` 进行调整,允许用户创建类似 Emacs/Spacemacs 的配置。 Edamagit 未来计划增加视图的更多交互性,扩展配置菜单,实现缺失的 Git/Magit 功能,增强 diff 和日志功能,并加入诸如二分查找、补丁和子树等功能。

A Hacker News thread discusses Edamagit, a VSCode extension aiming to replicate the functionality of Magit, the popular Emacs Git interface. Some argue that a true "Magit for VSCode" is impossible due to Emacs' unique package system allowing deep integration and customization. They highlight Magit's power as a Git API within Emacs, enabling users to seamlessly extend its functionality and integrate it with other Emacs tools. Others, including VSCode users, ask for specific examples of Magit's standout features. While acknowledging the convenience of GitLens and other Git extensions, some Emacs users emphasize Magit's seamless integration with text editing, its role as a Git API, and the extensive customization options available within the Emacs ecosystem. The discussion also touches upon the commitment required to master Emacs and Magit, contrasted with the out-of-the-box experience offered by other editors. Furthermore, some are sharing their experiences with alternative git UIs like `jjui`, `gitu` and jujutsu.
相关文章
  • (评论) 2024-09-10
  • 统一与分离差异 2023-10-25
  • VS Code 中的 PostgreSQL IDE 2025-05-23
  • (评论) 2025-02-26
  • (评论) 2024-07-27

  • 原文

    Magit for VSCode, inspired by the awesome original Magit.


    Keyboard driven Git interface

    Usage (Theme: Dracula)

    VSCode Command Default shortcut
    Magit Status alt+x g
    Magit File Popup alt+x alt+g
    Magit Dispatch alt+x ctrl+g
    Magit Help (when in status view) ?

    > Magit in VSCode Command palette will show you all available Magit actions from where you are.

    Keybindings inside edamagit

    Popup and dwim commands
      A Cherry-pick      b Branch           c Commit
      d Diff             f Fetch            F Pull
      I Ignore           l Log              m Merge
      M Remote           P Push             r Rebase
      t Tag              V Revert           X Reset
      y Show Refs        z Stash            shift+1 Run
      shift+5 Worktree   o Submodules       shift+4 Process Log
    
    Applying changes
      a Apply          s Stage          u Unstage
      v Reverse        S Stage all      U Unstage all
      k Discard
    
    Essential commands
      g        refresh current buffer
      TAB      toggle section at point
      RET      visit thing at point
      shift+4  show git process view
      q        exit / close magit view
    
      ctrl+j Move cursor to next entity
      ctrl+k Move cursor to previous entity
    

    • Forge-enabled: Enable Forge functionality (show pull requests, issues, etc from e.g. Github)
    • Display-buffer-function: Choose which side for magit windows to open on.
    • Hide-status-sections: Hide listed sections from status view.
    • Quick-switch-enabled: Automatically confirm switch menu after enabling a switch (e.g. --force)

    When used in a monorepo, you need to make sure that the subdirectory can detect the parent's .git.

    {
      "git.openRepositoryInParentFolders": "always",
    }

    All edamagit keybindings are customizable using VSCode's built-in keybindings.json.

    Below are bindings providing evil-magit / spacemacs like keybindings.

    The negative bindings, e.g. -magit.discard-at-point for key k, remove the default edamagit bindings and the collisions with the Vim extension.

    Open your keybindings.json and paste the following JSON snippet.

    Bindings - keybindings.json
      {
         "key": "g g",
         "command": "cursorTop",
         "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" 
      },
      { "key": "g r",
         "command": "magit.refresh",
         "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" 
      },
      {
        "key": "tab",
        "command": "extension.vim_tab",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'"
      },
      {
        "key": "tab",
        "command": "-extension.vim_tab"
      },
      {
        "key": "x",
        "command": "magit.discard-at-point",
        "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
      },
      {
        "key": "k",
        "command": "-magit.discard-at-point"
      },
      {
        "key": "-",
        "command": "magit.reverse-at-point",
        "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
      },
      {
        "key": "v",
        "command": "-magit.reverse-at-point"
      },
      {
        "key": "shift+-",
        "command": "magit.reverting",
        "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
      },
      {
        "key": "shift+v",
        "command": "-magit.reverting"
      },
      {
        "key": "shift+o",
        "command": "magit.resetting",
        "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
      },
      {
        "key": "shift+x",
        "command": "-magit.resetting"
      },
      {
        "key": "x",
        "command": "-magit.reset-mixed"
      },
      {
        "key": "ctrl+u x",
        "command": "-magit.reset-hard"
      }

    Feature requests as well as issues are welcome

    • More interactivity in second-tier views (commit view, stash view, etc)
    • Config menus

    Missing Git/Magit features

    • More diffing features
    • More logging features (#40)
    • Bisecting
    • Patches
    • Subtrees
    联系我们 contact @ memedata.com