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### Configuration
33
34You can configure how Zed hard wraps commit messages with the `preferred-line-length` setting of the "Git Commit" language. The default is `72`, but it can be set to any number of characters `0` or more.
35
36The Git Panel also allows configuring the `soft_wrap` setting to adjust how commit messages display while you are typing them in the Git Panel. The default setting is `editor_width`, however, `none`, `preferred_line_length`, and `bounded` are also options.
37
38#### Example
39
40```json
41"languages": {
42 "Git Commit": {
43 "soft_wrap": "editor_width",
44 "preferred_line_length": 72
45 },
46}
47```
48
49## Project Diff
50
51You 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.
52
53All of the changes displayed in the Project Diff behave exactly the same as any other multibuffer: they are all editable excerpts of files.
54
55You can stage or unstage each hunk as well as a whole file by hitting the buttons on the tab bar or their corresponding keybindings.
56
57<!-- Add media -->
58
59## Fetch, push, and pull
60
61Fetch, 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}.
62
63## Staging Workflow
64
65Zed has two primary staging workflows, using either the Project Diff or the panel directly.
66
67### Using the Project Diff
68
69In 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}).
70
71Similarly, 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}).
72
73### Using the Git Panel
74
75From 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.
76
77<!-- Show a set of changes with default staged -->
78
79Entries 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}.
80
81<!-- Add media -->
82
83## Committing
84
85Zed offers two commit textareas:
86
871. The first one is available right at the bottom of the Git Panel. Hitting {#kb git::Commit} immediately commits all of your staged changes.
882. 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.
89
90### Undoing a Commit
91
92As 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.
93In there, you can use the "Uncommit" button, which performs the `git reset HEADˆ--soft` command.
94
95### Configuring Commit Line Length
96
97By default, Zed sets the commit line length to `72` but it can be configured in your local `settings.json` file.
98
99Find more information about setting the `preferred-line-length` in the [Configuration](#configuration) section.
100
101## Stashing
102
103Git 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.
104
105### Creating Stashes
106
107To 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.
108
109### Managing Stashes
110
111Zed provides a comprehensive stash picker accessible via {#action git::ViewStash}. From the stash picker, you can:
112
113- **View stash list**: Browse all your saved stashes with their descriptions and timestamps
114- **Open diffs**: See exactly what changes are stored in each stash
115- **Apply stashes**: Apply stash changes to your working directory while keeping the stash entry
116- **Pop stashes**: Apply stash changes and remove the stash entry from the list
117- **Drop stashes**: Delete unwanted stash entries without applying them
118
119### Quick Stash Operations
120
121For faster workflows, Zed provides direct actions to work with the most recent stash:
122
123- **Apply latest stash**: Use {#action git::StashApply} to apply the most recent stash without removing it
124- **Pop latest stash**: Use {#action git::StashPop} to apply and remove the most recent stash
125
126### Stash Diff View
127
128When viewing a specific stash in the diff view, you have additional options available through the interface:
129
130- Apply the current stash to your working directory
131- Pop the current stash (apply and remove)
132- Remove the stash without applying changes
133
134To open the stash diff view, select a stash from the stash picker and use the {#action stash_picker::ShowStashItem} ({#kb stash_picker::ShowStashItem}) keybinding.
135
136## AI Support in Git
137
138Zed currently supports LLM-powered commit message generation.
139You 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.
140
141> 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.
142
143You 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.
144
145```json [settings]
146{
147 "agent": {
148 "version": "2",
149 "commit_message_model": {
150 "provider": "anthropic",
151 "model": "claude-3-5-haiku"
152 }
153 }
154}
155```
156
157<!-- Add media -->
158
159More advanced AI integration with Git features may come in the future.
160
161## Git Integrations
162
163Zed integrates with popular Git hosting services to ensure that Git commit hashes and references to Issues, Pull Requests, and Merge Requests become clickable links.
164
165Zed currently supports links to the hosted versions of
166[GitHub](https://github.com),
167[GitLab](https://gitlab.com),
168[Bitbucket](https://bitbucket.org),
169[SourceHut](https://sr.ht) and
170[Codeberg](https://codeberg.org).
171
172For self-hosted GitHub, GitLab, or Bitbucket instances, add them to the `git_hosting_providers` setting so commit hashes and permalinks resolve to your domain:
173
174```json [settings]
175{
176 "git_hosting_providers": [
177 {
178 "provider": "gitlab",
179 "name": "Corp GitLab",
180 "base_url": "https://git.example.corp"
181 }
182 ]
183}
184```
185
186Zed also has a Copy Permalink feature to create a permanent link to a code snippet on your Git hosting service.
187These links are useful for sharing a specific line or range of lines in a file at a specific commit.
188Trigger this action via the [Command Palette](./getting-started.md#command-palette) (search for `permalink`),
189by creating a [custom key bindings](key-bindings.md#custom-key-bindings) to the
190`editor::CopyPermalinkToLine` or `editor::OpenPermalinkToLine` actions
191or by simply right clicking and selecting `Copy Permalink` with line(s) selected in your editor.
192
193## Diff Hunk Keyboard Shortcuts
194
195When viewing files with changes, Zed displays diff hunks that can be expanded or collapsed for detailed review:
196
197- **Expand all diff hunks**: {#action editor::ExpandAllDiffHunks} ({#kb editor::ExpandAllDiffHunks})
198- **Collapse all diff hunks**: Press `Escape` (bound to {#action editor::Cancel})
199- **Toggle selected diff hunks**: {#action editor::ToggleSelectedDiffHunks} ({#kb editor::ToggleSelectedDiffHunks})
200- **Navigate between hunks**: {#action editor::GoToHunk} and {#action editor::GoToPreviousHunk}
201
202> **Tip:** The `Escape` key is the quickest way to collapse all expanded diff hunks and return to an overview of your changes.
203
204## Action Reference
205
206| Action | Keybinding |
207| ----------------------------------------- | ------------------------------------- |
208| {#action git::Add} | {#kb git::Add} |
209| {#action git::StageAll} | {#kb git::StageAll} |
210| {#action git::UnstageAll} | {#kb git::UnstageAll} |
211| {#action git::ToggleStaged} | {#kb git::ToggleStaged} |
212| {#action git::StageAndNext} | {#kb git::StageAndNext} |
213| {#action git::UnstageAndNext} | {#kb git::UnstageAndNext} |
214| {#action git::Commit} | {#kb git::Commit} |
215| {#action git::ExpandCommitEditor} | {#kb git::ExpandCommitEditor} |
216| {#action git::Push} | {#kb git::Push} |
217| {#action git::ForcePush} | {#kb git::ForcePush} |
218| {#action git::Pull} | {#kb git::Pull} |
219| {#action git::PullRebase} | {#kb git::PullRebase} |
220| {#action git::Fetch} | {#kb git::Fetch} |
221| {#action git::Diff} | {#kb git::Diff} |
222| {#action git::Restore} | {#kb git::Restore} |
223| {#action git::RestoreFile} | {#kb git::RestoreFile} |
224| {#action git::Branch} | {#kb git::Branch} |
225| {#action git::Switch} | {#kb git::Switch} |
226| {#action git::CheckoutBranch} | {#kb git::CheckoutBranch} |
227| {#action git::Blame} | {#kb git::Blame} |
228| {#action git::StashAll} | {#kb git::StashAll} |
229| {#action git::StashPop} | {#kb git::StashPop} |
230| {#action git::StashApply} | {#kb git::StashApply} |
231| {#action git::ViewStash} | {#kb git::ViewStash} |
232| {#action editor::ToggleGitBlameInline} | {#kb editor::ToggleGitBlameInline} |
233| {#action editor::ExpandAllDiffHunks} | {#kb editor::ExpandAllDiffHunks} |
234| {#action editor::ToggleSelectedDiffHunks} | {#kb editor::ToggleSelectedDiffHunks} |
235
236> Not all actions have default keybindings, but can be bound by [customizing your keymap](./key-bindings.md#user-keymaps).
237
238## Git CLI Configuration
239
240If 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`:
241
242```sh
243git config --global core.editor "zed --wait"
244```
245
246Or add the following to your shell environment (in `~/.zshrc`, `~/.bashrc`, etc):
247
248```sh
249export GIT_EDITOR="zed --wait"
250```