Skip to content

Add "Add to .gitignore" action in project_panel#47377

Merged
ChristopherBiscardi merged 5 commits intozed-industries:mainfrom
korbindeman:feat_gitignore_in_project_panel
Apr 23, 2026
Merged

Add "Add to .gitignore" action in project_panel#47377
ChristopherBiscardi merged 5 commits intozed-industries:mainfrom
korbindeman:feat_gitignore_in_project_panel

Conversation

@korbindeman
Copy link
Copy Markdown
Contributor

This PR adds a "Add to .gitignore" action to the project panel's right-click context menu. Similar to the "Restore File" action that I previously added, I frequently find myself wanting this in the project panel.

image

With the restore file option:
image

Notes:

  • Implementation: The add_to_gitignore function is essentially copy-pasted from git_panel.rs.

  • Error handling: Added toast notification on error, which is consistent with restore_file in project_panel and perform_checkout in git_panel.
    Note that add_to_gitignore in git_panel does NOT show a toast (just uses detach_and_log_err). I don't know if this is on purpose.
    To follow up, I can either: match the project_panel implementation to the git_panel one (no toast), or update the git_panel implementation to also show a toast on error.

  • Menu grouping: Previously "Restore File" and "View File History" were in separate sections, but both relate to git. With this third git action, I grouped all three together under a single separator (see screenshot).
    We could also keep "View File History" separate and only group "Restore File" + "Add to .gitignore" together (both modify the working tree state in some way), if we don't want to alter the existing UI too much.

Release Notes:

  • Added "Add to .gitignore" option to the project panel context menu for files in git repositories.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jan 22, 2026
@cole-miller
Copy link
Copy Markdown
Member

cole-miller commented Jan 31, 2026

Thanks! Could we extract the code to add a path to .gitignore to a crate (maybe project) where both project_panel and git_ui can refer to it? Other than that this seems good.

@korbindeman
Copy link
Copy Markdown
Contributor Author

Yes, done! I also made it work for directories as well (was just files).

@korbindeman
Copy link
Copy Markdown
Contributor Author

Hey @cole-miller, just checking in on the changes I made addressing your feedback on Feb 2. Let me know if there's anything else needed!

Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I've merged main and made some updates that were required from other refactors in the meantime.

This will create a new .gitignore if none exists, and add to if it does, which is super nice, thanks!

Image

@ChristopherBiscardi ChristopherBiscardi enabled auto-merge (squash) April 23, 2026 05:34
@ChristopherBiscardi ChristopherBiscardi merged commit e4e656f into zed-industries:main Apr 23, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants