1---
2description: Zed is a text editor that supports lots of Git features
3title: Zed Editor Git integration documentation
4---
5
6# Git
7
8Zed 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.
9
10Here's an overview of all currently supported features:
11
12- Committing
13- Staging, pushing, pulling, and fetching
14- Project Diff: A multibuffer view of all changes
15- Diff indicators in buffers and editor scrollbars
16- Inline diff toggle and reverts in the editor for unstaged changes
17- Git status in the Project Panel
18- Branch creating and switching
19- Git blame viewing
20- Git stash pop, apply, drop and view
21
22## Git Panel
23
24The Git Panel gives you a birds-eye view of the state of your working tree and of Git's staging area.
25
26You can open the Git Panel using {#action git_panel::ToggleFocus}, or by clicking the Git icon in the status bar.
27
28In 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.
29
30Zed monitors your repository so that changes you make on the command line are instantly reflected.
31
32## Project Diff
33
34You can see all of the changes captured by Git in Zed by opening the Project Diff ({#kb git::Diff}), accessible via the {#action git::Diff} action in the Command Palette or the Git Panel.
35
36All of the changes displayed in the Project Diff behave exactly the same as any other multibuffer: they are all editable excerpts of files.
37
38You can stage or unstage each hunk as well as a whole file by hitting the buttons on the tab bar or their corresponding keybindings.
39
40<!-- Add media -->
41
42## Fetch, push, and pull
43
44Fetch, 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: {#action git::Fetch}, {#action git::Push}, and {#action git::Pull}.
45
46## Staging Workflow
47
48Zed has two primary staging workflows, using either the Project Diff or the panel directly.
49
50### Using the Project Diff
51
52In 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 {#action git::StageAndNext} ({#kb git::StageAndNext}).
53
54Similarly, stage all hunks at the same time with the {#action git::StageAll} ({#kb git::StageAll}) keybinding and then immediately commit with {#action git::Commit} ({#kb git::Commit}).
55
56### Using the Git Panel
57
58From the panel, you can simply type a commit message and hit the commit button, or {#action git::Commit}. This will automatically stage all tracked files (indicated by a `[·]` in the entry's checkbox) and commit them.
59
60<!-- Show a set of changes with default staged -->
61
62Entries can be staged using each individual entry's checkbox. All changes can be staged using the button at the top of the panel, or {#action git::StageAll}.
63
64<!-- Add media -->
65
66## Committing
67
68Zed offers two commit textareas:
69
701. The first one is available right at the bottom of the Git Panel. Hitting {#kb git::Commit} immediately commits all of your staged changes.
712. The second is available via the action {#action git::ExpandCommitEditor} or via hitting the {#kb git::ExpandCommitEditor} while focused in the Git Panel commit textarea.
72
73### Undoing a Commit
74
75As 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.
76In there, you can use the "Uncommit" button, which performs the `git reset HEADˆ--soft` command.
77
78## Stashing
79
80Git 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.
81
82### Creating Stashes
83
84To stash all your current changes, use the {#action git::StashAll} action. This will save both staged and unstaged changes to a new stash entry and clean your working directory.
85
86### Managing Stashes
87
88Zed provides a comprehensive stash picker accessible via {#action git::ViewStash}. From the stash picker, you can:
89
90- **View stash list**: Browse all your saved stashes with their descriptions and timestamps
91- **Open diffs**: See exactly what changes are stored in each stash
92- **Apply stashes**: Apply stash changes to your working directory while keeping the stash entry
93- **Pop stashes**: Apply stash changes and remove the stash entry from the list
94- **Drop stashes**: Delete unwanted stash entries without applying them
95
96### Quick Stash Operations
97
98For faster workflows, Zed provides direct actions to work with the most recent stash:
99
100- **Apply latest stash**: Use {#action git::StashApply} to apply the most recent stash without removing it
101- **Pop latest stash**: Use {#action git::StashPop} to apply and remove the most recent stash
102
103### Stash Diff View
104
105When viewing a specific stash in the diff view, you have additional options available through the interface:
106
107- Apply the current stash to your working directory
108- Pop the current stash (apply and remove)
109- Remove the stash without applying changes
110
111To open the stash diff view, select a stash from the stash picker and use the {#action stash_picker::ShowStashItem} ({#kb stash_picker::ShowStashItem}) keybinding.
112
113## AI Support in Git
114
115Zed currently supports LLM-powered commit message generation.
116You 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 {#action git::GenerateCommitMessage} ({#kb git::GenerateCommitMessage}) keybinding.
117
118> 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](./ai/configuration.md) to learn how to do so.
119
120You can specify your preferred model to use by providing a `commit_message_model` agent setting. See [Feature-specific models](./ai/agent-settings.md#feature-specific-models) for more information.
121
122```json [settings]
123{
124 "agent": {
125 "version": "2",
126 "commit_message_model": {
127 "provider": "anthropic",
128 "model": "claude-3-5-haiku"
129 }
130 }
131}
132```
133
134<!-- Add media -->
135
136More advanced AI integration with Git features may come in the future.
137
138## Git Integrations
139
140Zed integrates with popular Git hosting services to ensure that Git commit hashes and references to Issues, Pull Requests, and Merge Requests become clickable links.
141
142Zed currently supports links to the hosted versions of
143[GitHub](https://github.com),
144[GitLab](https://gitlab.com),
145[Bitbucket](https://bitbucket.org),
146[SourceHut](https://sr.ht) and
147[Codeberg](https://codeberg.org).
148
149Zed also has a Copy Permalink feature to create a permanent link to a code snippet on your Git hosting service.
150These links are useful for sharing a specific line or range of lines in a file at a specific commit.
151Trigger this action via the [Command Palette](./getting-started.md#command-palette) (search for `permalink`),
152by creating a [custom key bindings](key-bindings.md#custom-key-bindings) to the
153`editor::CopyPermalinkToLine` or `editor::OpenPermalinkToLine` actions
154or by simply right clicking and selecting `Copy Permalink` with line(s) selected in your editor.
155
156## Diff Hunk Keyboard Shortcuts
157
158When viewing files with changes, Zed displays diff hunks that can be expanded or collapsed for detailed review:
159
160- **Expand all diff hunks**: {#action editor::ExpandAllDiffHunks} ({#kb editor::ExpandAllDiffHunks})
161- **Collapse all diff hunks**: Press `Escape` (bound to {#action editor::Cancel})
162- **Toggle selected diff hunks**: {#action editor::ToggleSelectedDiffHunks} ({#kb editor::ToggleSelectedDiffHunks})
163- **Navigate between hunks**: {#action editor::GoToHunk} and {#action editor::GoToPreviousHunk}
164
165> **Tip:** The `Escape` key is the quickest way to collapse all expanded diff hunks and return to an overview of your changes.
166
167## Action Reference
168
169| Action | Keybinding |
170| ----------------------------------------- | ------------------------------------- |
171| {#action git::Add} | {#kb git::Add} |
172| {#action git::StageAll} | {#kb git::StageAll} |
173| {#action git::UnstageAll} | {#kb git::UnstageAll} |
174| {#action git::ToggleStaged} | {#kb git::ToggleStaged} |
175| {#action git::StageAndNext} | {#kb git::StageAndNext} |
176| {#action git::UnstageAndNext} | {#kb git::UnstageAndNext} |
177| {#action git::Commit} | {#kb git::Commit} |
178| {#action git::ExpandCommitEditor} | {#kb git::ExpandCommitEditor} |
179| {#action git::Push} | {#kb git::Push} |
180| {#action git::ForcePush} | {#kb git::ForcePush} |
181| {#action git::Pull} | {#kb git::Pull} |
182| {#action git::Fetch} | {#kb git::Fetch} |
183| {#action git::Diff} | {#kb git::Diff} |
184| {#action git::Restore} | {#kb git::Restore} |
185| {#action git::RestoreFile} | {#kb git::RestoreFile} |
186| {#action git::Branch} | {#kb git::Branch} |
187| {#action git::Switch} | {#kb git::Switch} |
188| {#action git::CheckoutBranch} | {#kb git::CheckoutBranch} |
189| {#action git::Blame} | {#kb git::Blame} |
190| {#action git::StashAll} | {#kb git::StashAll} |
191| {#action git::StashPop} | {#kb git::StashPop} |
192| {#action git::StashApply} | {#kb git::StashApply} |
193| {#action git::ViewStash} | {#kb git::ViewStash} |
194| {#action editor::ToggleGitBlameInline} | {#kb editor::ToggleGitBlameInline} |
195| {#action editor::ExpandAllDiffHunks} | {#kb editor::ExpandAllDiffHunks} |
196| {#action editor::ToggleSelectedDiffHunks} | {#kb editor::ToggleSelectedDiffHunks} |
197
198> Not all actions have default keybindings, but can be bound by [customizing your keymap](./key-bindings.md#user-keymaps).
199
200## Git CLI Configuration
201
202If you would like to also use Zed for your [git commit message editor](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_editor) when committing from the command line you can use `zed --wait`:
203
204```sh
205git config --global core.editor "zed --wait"
206```
207
208Or add the following to your shell environment (in `~/.zshrc`, `~/.bashrc`, etc):
209
210```sh
211export GIT_EDITOR="zed --wait"
212```