desktop / desktop/desktop

Prohibit deleting a branch that contains stashed changes

Open
#13,714 5 comments 3 reactions 0 assignees View on GitHub
enhancement not-planned
Dominant language
TypeScript
Stars
21.8k
Forks
10.5k
Avg merge
1d 15h
Merged PRs (30d)
25

Description

### Describe the feature or problem you’d like to solve

Very often I switch between branches, and sometimes I do not publish my branch until I did something useful. And when I switch to another branch to do my work, I stash changes in he old branch.

But it happened to me multiple times that I decided to delete a branch (that is not published on the remote) and it contains stashed changes. And ops - I need these stashed changes, but now they are gone, and I need to remember the config adjustments or code changes that I wanted to keep, but that was gone when I delete the branch with all the stashed changes.

### Proposed solution

I think that it will be beneficial to keep the stashed changes in either way:
- prevent deleting of a branch that contains any stashed changes. I will need manually to restore stashed changes and revert them. This way it minimises risks of losing any useful changes that I need to keep
- move the stashed changes to a new branch (to master by default). But in this case it's very important to do not override already stashed changes in the master branch (because we will lose other stashed changes that was before in the master branch). In this case we just need to ad stashed changes to a stack of the stashed changes, or combine changes together

### Additional context

This way it will be much easier to be confident that changes that are useful but you don't want to commit them - will stay with you as long as you want. Even if it's local configuration files that should be useful only personally for you.

Thanks.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the branch-deletion flow and how Git stashes are associated with branches. Compare the two proposed behaviors and check existing tests around branch deletion and stashes. Done means choosing and implementing a clear preservation rule without overwriting other stashes, with tests covering deletion when stashed changes exist.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, git, typescript
Domain
desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.