Git Integration

Manage your version control workflows directly within Zed

Git Integration in Zed

Zed provides seamless Git integration to help you manage your version control workflows without leaving the editor. From viewing file status to resolving merge conflicts, Zed's Git features are designed to make version control intuitive and efficient.

Key Git features in Zed include:

  • Visual indicators for file changes and status
  • Inline diff views to review changes
  • Branch management
  • Commit, push, and pull operations
  • Conflict resolution tools
  • Blame and history viewing
Git Integration in Zed

Git Status Indicators

Zed displays Git status information throughout the interface:

File Status in Project Panel

The project panel shows Git status for each file using color and symbols:

  • Green: New files (untracked)
  • Blue: Modified files
  • Red: Deleted files
  • Yellow: Renamed or moved files
  • Purple: Merge conflicts
Git Status Indicators

Status Bar Information

The status bar shows Git branch information and status:

  • Current branch name
  • Sync status (ahead/behind remote)
  • Number of changed files

Click on the branch name in the status bar to quickly switch branches or perform common Git operations.

Viewing Changes

Gutter Indicators

The editor gutter (margin) shows line-by-line change status:

  • Green bar: Added lines
  • Blue bar: Modified lines
  • Red triangle: Deleted lines

Inline Diff View

To see detailed changes within a file:

  1. Open Diff View

    Click on a changed line's gutter indicator or press ShiftP and type "Git: Show Changes" to see the diff view.

  2. Review Changes

    The diff view shows a side-by-side comparison of the current state and the last committed version.

    Inline Diff View
  3. Navigate Changes

    Use Alt and Alt to jump between changed regions.

Common Git Operations

Staging Changes

Add files or changes to the staging area:

  • Stage a File: Right-click on a file in the project panel and select "Stage Changes"
  • Stage Selected Lines: Select lines in the editor, right-click, and choose "Stage Selected Lines"
  • Stage All Changes: Press ShiftP and type "Git: Stage All Changes"

Committing

Commit your staged changes:

  1. Open Commit Dialog

    Press ShiftP and type "Git: Commit" or click on the Git icon in the status bar.

  2. Enter Commit Message

    Type a descriptive commit message in the commit dialog.

    Commit Dialog
  3. Commit

    Click "Commit" or press CtrlEnter to finalize the commit.

Pushing and Pulling

Synchronize with remote repositories:

  • Push: Press ShiftP and type "Git: Push"
  • Pull: Press ShiftP and type "Git: Pull"
  • Fetch: Press ShiftP and type "Git: Fetch"

Zed's status bar displays pull/push status, showing how many commits you're ahead or behind the remote branch.

Working with Branches

Viewing Branches

See all available branches:

  • Click on the branch name in the status bar
  • Press ShiftP and type "Git: Checkout to..."

Creating New Branches

  1. Open Branch Dialog

    Press ShiftP and type "Git: Create Branch" or click the branch name in the status bar and select "Create new branch...".

  2. Name the Branch

    Enter a name for your new branch.

  3. Select Base Branch

    Choose which existing branch to base your new branch on, typically main or master.

    Creating a New Branch

Switching Branches

Change to a different branch:

  • Click the branch name in the status bar and select a branch
  • Press ShiftP and type "Git: Checkout to..." then select a branch

You can create and checkout a new branch in one step with the "Git: Create and Checkout Branch" command.

Handling Merge Conflicts

Identifying Conflicts

When a merge conflict occurs:

  • Conflicted files are marked with a purple indicator in the project panel
  • The status bar shows a conflict indicator
  • Conflict markers appear in the affected files

Resolving Conflicts

Zed provides tools to help resolve merge conflicts:

  1. Open Conflict Editor

    Open the conflicted file to see the conflict markers and in-editor resolution tools.

  2. Choose Between Changes

    Zed displays "Current Changes" (yours) and "Incoming Changes" (theirs) with buttons to accept either version or manually edit the file to combine both.

    Merge Conflict Resolution
  3. Mark as Resolved

    After editing the file to resolve the conflict, save it and stage the changes to mark the conflict as resolved.

Remember to complete the merge by creating a merge commit after resolving all conflicts.

Git History and Blame

Viewing File History

See the history of changes to a file:

  • Right-click on a file in the project panel and select "Git: Show File History"
  • Press ShiftP and type "Git: Show File History" with the file open

Git Blame

See who last modified each line of a file:

  • Press ShiftP and type "Git: Toggle Blame"
  • Right-click in the editor and select "Git: Toggle Blame"
Git Blame View

Click on blame information to see the full commit details and navigate to that specific commit in the history.

Advanced Git Features

Interactive Rebase

Reorganize, combine, or modify past commits:

  • Press ShiftP and type "Git: Interactive Rebase"
  • Follow the interactive prompts to reorder, squash, or edit commits

Stashing

Temporarily store changes to work on something else:

  • Create Stash: ShiftP and type "Git: Stash Changes"
  • Apply Stash: ShiftP and type "Git: Apply Stash"
  • Pop Stash: ShiftP and type "Git: Pop Stash"

Cherry-Picking

Apply specific commits from one branch to another:

  • Press ShiftP and type "Git: Cherry Pick"
  • Select the commit(s) you want to apply to your current branch

Git Configuration in Zed

Git Settings

Customize Git behavior in Zed:

  • Press , to open Settings
  • Search for "git" to find Git-related settings

Common Git Settings

json
{ "git.enabled": true, "git.autofetch": true, "git.confirmSync": false, "git.enableSmartCommit": true, "git.showInlineBlame": true }

Zed respects your global Git configuration files (like .gitconfig), so your username, email, and authentication settings are automatically applied.

What's Next?

Now that you've learned how to use Git within Zed, you're ready to explore how to enhance Zed's functionality with extensions and plugins that can customize your development experience.