-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged branches stay around until they're manually deleted #750
Comments
Copying my comment from #1128 (comment) at @shiftkey request.
|
After I merge PRs on GitHub, their locally checked out branches end up stale in my local repo. So I often run locally the following command: git branch --merged | grep -v "master" | grep -v "*"| xargs git branch -d I'm thinking about opening a PR that adds a "Prune merged branches" (needs better wording) to the Repository or Branch menus. Is this what this issue is about? Or is it about pruning remote branches that were fetched locally? |
@caiofbpa this is about pruning local branches. Your original thinking is correct. |
Ugh this issue is over a year old, too bad. I thought more people would be in need of something like this. |
@jpike88 I've updated the issue with extra details about the feature and what's required, to make clear that this is something an external contributor can pick up and have a go at! |
@billygriffin could you clarify which branches we should be pruning. Specifically, should I
If we go with option 1, there's a chance the app could be closed mid-way through the cleanup, meaning we need to persist this state to some longer term place than memory. Do you have a preferred way of handling this? Do we resume when app opens or when the scheduled time arrives in situations like this? If we go with option 2, that may lead to a scenario where the branches are never marked for cleanup because the user briefly opened the repo before moving on, not giving us enough time to kick off our cleanup process. |
Good question @iAmWillShepherd.
If the app is closed mid-way through the cleanup, then the next time we check, wouldn't it just do the check again and anything that didn't get caught the first time would now get pruned appropriately? I'm not certain why we'd need to persist state. It doesn't really matter if it doesn't get all the way cleaned up if we'll be checking again at some interval, right? |
I think we want option 1 but with some stipulations, as @iAmWillShepherd and @billygriffin mentioned above: that prune when the app when it starts again if it wasn't completed. If we do that and we prune at X time each day (for this example 6pm), it sounds like we'd have two actions/checkpoints
** we can store when we have completed pruning or when we start to prune. it’ll affect very few people but it depends on whether we want to re-prune again on startup if they quit at 6:00:05pm vs. just waiting until the next day I think the biggest risk is performance. We're going to have to see how much of a performance hit we take during pruning, though. If it's too intense, we might have to change to option 2. Maybe there's a quick way to assess that before we finalize the feature? |
This should take into account the last time the branch was checked out/created. I can imagine some use cases where it might be useful to locally create a branch with an old revision where it would be annoying if the branch was deleted. |
Is this restricted only to Github.com hosted repositories or is it actually:
I'm asking because I use the Desktop client as a general purpose git tool, not just solely for github.com projects. |
@GhostLyrics Thanks for the question! For now it is restricted to GitHub.com. We chose to make this very conservative since it is destructive and we have a much better understanding of the information we receive from the GitHub API relative to other hosting providers. We likely won’t optimize for other services in the near term but we aren’t opposed to revisiting down the line. |
Do you check if there are stashed changes (or just changes) for the branch? |
@VelocityIsNotSpeed we don’t currently but we’ve talked about adding that logic. would you be willing to open a new issue for that? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
git remote prune origin
|
still the issue is not resolved |
This should be at least an option that user can opt-into for non-GitHub hosted repositories. When working with non-GitHub hosted repositories with a lot of active contributors, pull becomes useless (always fails with an error) as many merged branches exist and pruning is required. |
Any idea on what the progress of this is? |
@JosephTLyons This is shipped, with the caveat that it's only for repos on GitHub.com. Due to feedback while we were building this, we decided to use 14 days as the constraint prior to pruning local branches so we're not pruning branches people were planning to reuse. |
Thanks for the information, I didn't realize it had shipped.. most likely because I ended up manually deleting branches before 14 days. Thanks for letting me know. |
I understand why you would wait 14 days to prune, and i like the option to delete manually in the app once i've merged and deleted the branch on github.com. But....when manually deleting a branch in. the app, the pop up warning states that the branch still exists on remote. Is this a bug? |
@TaxiTweedy Are you saying you're getting the popup even when the branch no longer exists on the remote? If so, I'm guessing this might be a particularly tricky condition where the app hasn't yet fetched and therefore isn't aware yet that the branch has been deleted. |
Yes, exactly. A branch was merged and deleted on remote but appears in the desktop app. This in itself i understand (pruning after 14 days) however the manual option to delete warns that it still exists. I waited several hours after deleting on remote before trying to delete (on app) to see if it was a fetch issue. It feels like the language on the pop up (saying branch exists on remote) was written as static and perhaps doesn't change even if it has been deleted from remote? |
@TaxiTweedy I was able to reproduce this behavior. There are two ways to delete a branch: 1) via branch dropdown context menu and 2) via app branch menu. The app branch menu was displaying the correct dialog message, but the branch dropdown context menu was not. I have opened a PR to address this bug. Thank you for the report! |
I did not know this (and also just discovered the shortcut)! Thank you for the heads up! |
@billygriffin I am still having the same problem as @TaxiTweedy are reporting. After merging a pull request om GitHub.com i choose to delete the branch from the pull request interface. When returning to GitHub Desktop it shows me an action tip to publish the branch: I thought that GitHub Desktop should prune branches deleted from GitHub.com after pull request merge? |
True @Garkk I am having the same issue... |
Why is this after 6 years still not a thing? People that are just starting out feel like they will break something here. Our GitHub repositorys are set up to delete branches of merged PRs. That leaves us with a bunch of non existing branches that are still visible in Github Desktop. A small button "Sync branches with remote" would help tremendously. |
Why is this issue closed when it was never addressed and other issues are pointed here as the place to follow it? |
I believe, @Slluxx and @ekwoka, that this feature actually is implemented. Scrolling through earlier comments in this issue I find:
And from the changelog I find that the feature was implemented in version 2.1.0 released in July 2019:
Unfortunately there seems to be even another big limitation for my part, and that is that only branches and pull requests that use normal merges will be pruned. If your workflow uses squash and merge you are out of luck, as this is not detected. Any improvements to this already implemented issue should probably be registered as a new issue. |
Thanks. I tried to look through it but I couldn't get much that clarified if and how it worked (it was just clear it wasn't working). 2 weeks can be quite long but manageable, but yes, we do squash and merge everywhere, so it won't work anyway, sadly. |
These tools may be of use to you: |
Yes, I've been using |
@shiftkey writes
Problem statement:
Branches stick around in Desktop indefinitely until manually deleted. I want the branches that show up in Desktop to be relevant to me and not muddied by stale branches.
Proposed solution:
If
then
Considerations:
gh-pages
), we should skip pruning those branches.Questions:
The text was updated successfully, but these errors were encountered: