Git
Zed currently offers a set of fundamental Git features, with support coming in the future for more advanced ones, like conflict resolution tools, line by line staging, and more.
Here's an overview of all currently supported features:
- Committing
- Staging, pushing, pulling, and fetching
- Project Diff: A multibuffer view of all changes
- Diff indicators in buffers and editor scrollbars
- Inline diff toggle and reverts in the editor for unstaged changes
- Git status in the Project Panel
- Branch creating and switching
- Git blame viewing
- Git stash pop, apply, drop and view
Git Panel
The Git Panel gives you a birds-eye view of the state of your working tree and of Git's staging area.
You can open the Git Panel using git panel: toggle focus, or by clicking the Git icon in the status bar.
In the panel you can see the state of your project at a glance—which repository and branch are active, what files have changed and the current staging state of each file.
Zed monitors your repository so that changes you make on the command line are instantly reflected.
Project Diff
You can see all of the changes captured by Git in Zed by opening the Project Diff (ctrl-g d|ctrl-g d), accessible via the git: diff action in the Command Palette or the Git Panel.
All of the changes displayed in the Project Diff behave exactly the same as any other multibuffer: they are all editable excerpts of files.
You can stage or unstage each hunk as well as a whole file by hitting the buttons on the tab bar or their corresponding keybindings.
Fetch, push, and pull
Fetch, push, or pull from your Git repository in Zed via the buttons available on the Git Panel or via the Command Palette by looking at the respective actions: git: fetch, git: push, and git: pull.
Staging Workflow
Zed has two primary staging workflows, using either the Project Diff or the panel directly.
Using the Project Diff
In the Project Diff view, you can focus on each hunk and stage them individually by clicking on the tab bar buttons or via the keybindings git: stage and next (cmd-y|alt-y).
Similarly, stage all hunks at the same time with the git: stage all (cmd-ctrl-y|ctrl-space) keybinding and then immediately commit with git: commit (cmd-enter|ctrl-enter).
Using the Git Panel
From the panel, you can simply type a commit message and hit the commit button, or git: commit. This will automatically stage all tracked files (indicated by a [·] in the entry's checkbox) and commit them.
Entries can be staged using each individual entry's checkbox. All changes can be staged using the button at the top of the panel, or git: stage all.
Committing
Zed offers two commit textareas:
- The first one is available right at the bottom of the Git Panel. Hitting cmd-enter|ctrl-enter immediately commits all of your staged changes.
- The second is available via the action
git: expand commit editoror via hitting the shift-escape| while focused in the Git Panel commit textarea.
Undoing a Commit
As soon as you commit in Zed, in the Git Panel, you'll see a bar right under the commit textarea, which will show the recently submitted commit.
In there, you can use the "Uncommit" button, which performs the git reset HEADˆ--soft command.
Stashing
Git stash allows you to temporarily save your uncommitted changes and revert your working directory to a clean state. This is particularly useful when you need to quickly switch branches or pull updates without committing incomplete work.
Creating Stashes
To stash all your current changes, use the git: stash all action. This will save both staged and unstaged changes to a new stash entry and clean your working directory.
Managing Stashes
Zed provides a comprehensive stash picker accessible via git: view stash. From the stash picker, you can:
- View stash list: Browse all your saved stashes with their descriptions and timestamps
- Open diffs: See exactly what changes are stored in each stash
- Apply stashes: Apply stash changes to your working directory while keeping the stash entry
- Pop stashes: Apply stash changes and remove the stash entry from the list
- Drop stashes: Delete unwanted stash entries without applying them
Quick Stash Operations
For faster workflows, Zed provides direct actions to work with the most recent stash:
- Apply latest stash: Use
git: stash applyto apply the most recent stash without removing it - Pop latest stash: Use
git: stash popto apply and remove the most recent stash
Stash Diff View
When viewing a specific stash in the diff view, you have additional options available through the interface:
- Apply the current stash to your working directory
- Pop the current stash (apply and remove)
- Remove the stash without applying changes
To open the stash diff view, select a stash from the stash picker and use the stash picker: show stash item (ctrl-shift-v|ctrl-shift-v) keybinding.
AI Support in Git
Zed currently supports LLM-powered commit message generation.
You can ask AI to generate a commit message by focusing on the message editor within the Git Panel and either clicking on the pencil icon in the bottom left, or reaching for the git: generate commit message (alt-tab|alt-l) keybinding.
Note that you need to have an LLM provider configured for billing purposes, either via your own API keys or trialing/paying for Zed's hosted AI models. Visit the AI configuration page to learn how to do so.
You can specify your preferred model to use by providing a commit_message_model agent setting. See Feature-specific models for more information.
{
"agent": {
"version": "2",
"commit_message_model": {
"provider": "anthropic",
"model": "claude-3-5-haiku"
}
}
}
More advanced AI integration with Git features may come in the future.
Git Integrations
Zed integrates with popular Git hosting services to ensure that Git commit hashes and references to Issues, Pull Requests, and Merge Requests become clickable links.
Zed currently supports links to the hosted versions of GitHub, GitLab, Bitbucket, SourceHut and Codeberg.
Zed also has a Copy Permalink feature to create a permanent link to a code snippet on your Git hosting service.
These links are useful for sharing a specific line or range of lines in a file at a specific commit.
Trigger this action via the Command Palette (search for permalink),
by creating a custom key bindings to the
editor::CopyPermalinkToLine or editor::OpenPermalinkToLine actions
or by simply right clicking and selecting Copy Permalink with line(s) selected in your editor.
Diff Hunk Keyboard Shortcuts
When viewing files with changes, Zed displays diff hunks that can be expanded or collapsed for detailed review:
- Expand all diff hunks:
editor: expand all diff hunks(cmd-"|ctrl-") - Collapse all diff hunks: Press
Escape(bound toeditor: cancel) - Toggle selected diff hunks:
editor: toggle selected diff hunks(cmd-'|ctrl-') - Navigate between hunks:
editor: go to hunkandeditor: go to previous hunk
Tip: The
Escapekey is the quickest way to collapse all expanded diff hunks and return to an overview of your changes.
Action Reference
| Action | Keybinding |
|---|---|
git: add | No default binding |
git: stage all | cmd-ctrl-y |
git: unstage all | cmd-ctrl-shift-y |
git: toggle staged | space |
git: stage and next | cmd-y |
git: unstage and next | cmd-shift-y |
git: commit | cmd-enter |
git: expand commit editor | shift-escape |
git: push | ctrl-g up |
git: force push | ctrl-g shift-up |
git: pull | ctrl-g down |
git: fetch | ctrl-g ctrl-g |
git: diff | ctrl-g d |
git: restore | cmd-alt-z |
git: restore file | cmd-delete |
git: branch | No default binding |
git: switch | No default binding |
git: checkout branch | No default binding |
git: blame | cmd-alt-g b |
git: stash all | No default binding |
git: stash pop | No default binding |
git: stash apply | No default binding |
git: view stash | No default binding |
editor: toggle git blame inline | No default binding |
editor: expand all diff hunks | cmd-" |
editor: toggle selected diff hunks | cmd-' |
Not all actions have default keybindings, but can be bound by customizing your keymap.
Git CLI Configuration
If you would like to also use Zed for your git commit message editor when committing from the command line you can use zed --wait:
git config --global core.editor "zed --wait"
Or add the following to your shell environment (in ~/.zshrc, ~/.bashrc, etc):
export GIT_EDITOR="zed --wait"