# git_ui: Add \`Add to \.git/info/exclude\` option to context menus \(\#57044\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cc105a4459260ceef1a4b259ea14ad88c225d1f3)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cc105a4459260ceef1a4b259ea14ad88c225d1f3

Requested commit: cc105a4459260ceef1a4b259ea14ad88c225d1f3

Commit: cc105a4459260ceef1a4b259ea14ad88c225d1f3

Tree: 0362cff585e0cb3d8fbaca778b96214287637a8f

Author: Tom Planche

Committer: GitHub

## Message

```
git_ui: Add `Add to .git/info/exclude` option to context menus (#57044)

This is an unsolicited contribution, I hope that's ok. The feature is
small and I didn't want to open a discussion just for this.

There was no way to write to `.git/info/exclude` from Zed, so I added
one.

The "Add to .gitignore" action in the project panel and git panel
context menus is now grouped under a "Git" submenu, with a new "Add to
.git/info/exclude" action next to it.

Both actions:

- skip the write if the pattern is already there
- make sure there's a trailing newline
- show an error toast if something goes wrong
- fail gracefully on remote repositories

In the git panel both entries are disabled unless the file is untracked,
same as the gitignore action was before.

The write logic is shared via a small private helper, covered by two
unit tests.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added `Add to .git/info/exclude` option under a new `Git` submenu in
the project panel and git panel context menus, alongside the existing
`Add to .gitignore` action.

---------

Co-authored-by: Cole Miller <cole@zed.dev>
```

## Parents

- [300fde7b709ce5638bdea34eba3b070fe5bc9b19](https://git.cafe/gitcafe/zed/commit/300fde7b709ce5638bdea34eba3b070fe5bc9b19?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cc105a4459260ceef1a4b259ea14ad88c225d1f3?format=markdown)
