edamagit

repository·develop·Indexed 23 days ago

https://github.com/kahole/edamagit

A keyboard-driven Git interface for Visual Studio Code inspired by Magit. It provides high-density views and command popups for managing Git repositories, including support for staging, branching, cherry-picking, bisecting, and Forge integration (GitHub/GitLab). Features include specialized keybindings, Vim integration via VSCodeVim, and monorepo support.

Tokens
17.2K
Snippets
21
Records
115
Agent score
81%

What's inside edamagit

  1. Navigate edamagit menus

    develop

    edamagit uses a menu-driven system based on VSCode's QuickPick. Most git commands are accessed via a prefix key that opens a specific menu.

    • ?: Open the help view to see all available menus and their prefix keys.
    • b: Open the Branching menu.
    • c: Open the Committing menu.

    To perform an action from a menu:

    1. Press the menu prefix key (e.g., b).
    2. Press the specific key for the action (e.g., c for Checkout new branch).
    3. Follow the prompts (e.g., select a branch with arrow keys and press Enter).
  2. Use switches (flags) with commands

    develop

    Many git commands support switches or flags (e.g., push --force). In edamagit, you can toggle these via a switches menu.

    1. Open a command menu (e.g., for pushing or branching).
    2. Press - to activate the switches menu.
    3. Toggle a switch by pressing its letter (e.g., press F for --force).
    4. Press Enter to confirm the selection.
    5. Active switches will be listed in the 'Switches' menu entry.
  3. Use edamagit keybindings

    develop

    Once inside an edamagit view, use these keyboard shortcuts to navigate and perform Git operations.

    These commands are typically available via a popup menu:

    • b: Branch
    • c: Commit
    • f: Fetch
    • F: Pull
    • m: Merge
    • P: Push
    • r: Rebase
    • z: Stash
    • A: Cherry-pick
    • d: Diff
    • l: Log
    • V: Revert
    • X: Reset
    • t: Tag

    Applying changes

    • s: Stage
    • u: Unstage
    • a: Apply
    • v: Reverse
    • k: Discard
    • S: Stage all
    • U: Unstage all

    Essential navigation and view commands

    • g: Refresh current buffer
    • TAB: Toggle section at point
    • RET: Visit thing at point
    • q: Exit / close magit view
    • ctrl+j: Move cursor to next entity
    • ctrl+k: Move cursor to previous entity
    • shift+4: Show git process view
    • shift+5: Worktree
  4. Configure Vim bindings for edamagit (VSCodeVim)

    develop

    If you use the VSCodeVim extension, you can customize edamagit keybindings to match evil-magit or spacemacs styles. This involves adding specific mappings to your keybindings.json and using negative bindings (e.g., -magit.discard-at-point) to prevent collisions with default Vim behavior.

    {
       "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' && !inlineEditIsVisible && 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"
    }
  5. Use the Status View

    develop

    The Status View is the primary interface for interacting with your git repository.

    To open it:

    • Press Alt+x g (hold Alt and x together, then press g).
    • Or run the command 'Magit Status' from the VSCode command palette.

    Once in the Status View, use these keys to navigate and manage changes:

    • Tab: Fold or unfold sections, files, or change hunks.
    • s: Stage the entity under the cursor (file, hunk, or selected part of a hunk).
    • u: Unstage the entity under the cursor.
    • a: Apply the entity under the cursor (e.g., apply a stash).
    • k: Delete the entity under the cursor (e.g., delete a change, file, or stash).
    • Enter: Open the entity under the cursor (e.g., show commit details or open a file).
  6. Launch edamagit from VSCode

    develop

    You can access the edamagit interface using VSCode commands or the Command Palette. Use the following default shortcuts to open the main views:

    • Magit Status: alt+x g (Opens the main status view)
    • Magit File Popup: alt+x alt+g (Opens a popup for file-specific actions)
    • Magit Dispatch: alt+x ctrl+g (Opens the dispatch menu)

    Alternatively, open the VSCode Command Palette and type > Magit to see a list of all available Magit actions.

  7. Commit changes in edamagit

    develop

    To commit staged changes:

    1. Press c to open the committing menu.
    2. Press c again to start a normal commit.
    3. An editor will open for your commit message. Write your message.
    4. To finish the commit:
      • Press ctrl+c ctrl+c.
      • Or manually save and close the commit-message editor.

    To abort a commit:

    • Press ctrl+c ctrl+k.
    • Or save and close the editor with an empty message.
  8. Enable monorepo support

    develop

    If you are using edamagit in a monorepo, ensure that the subdirectories can detect the parent's .git directory by adding this to your VSCode settings:

    {
      "git.openRepositoryInParentFolders": "always"
    }
    {
      "git.openRepositoryInParentFolders": "always",
    }
  9. Fixup and Instant Fixup

    develop

    Fixup

    Creates a commit that is intended to be merged into a previous commit. It prompts you to choose a commit via MagitUtils.chooseCommit and then runs git commit --fixup <sha>.

    Instant Fixup

    An automated workflow for applying a fixup. It prompts you to choose a commit, then:

    1. Runs git commit --no-gpg-sign --no-edit --fixup=<shortHash> --.
    2. Automatically runs an interactive rebase (git rebase -i --autosquash --autostash <sha>~) using the GIT_SEQUENCE_EDITOR set to true to allow the process to complete without manual intervention.
  10. Cancel Git commands using CancellationToken

    develop
    To prevent long-running Git commands (like git fetch or git pull) from hanging, you can pass a VSCode CancellationToken via the SpawnOptions.cancellationToken property. If the token is cancelled, the underlying child process is killed, and the run function rejects with a CancellationError.