-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
git delete-merged-branches
can delete default branch such as master
#1132
Comments
It seems that it is because the default branch is
Either you can configure the default branch to |
It seems the git-extras/helper/git-extra-utility Lines 8 to 19 in 5f19424
|
So you can configure the default branch to |
Yes but wouldn't that be better if git-extras discover this automatically, using the commands above ? |
Would you happen to have any suggestions? The |
@spacewander Sorry for the late reply. Yes I think what I proposed in the top message could help resolve the default branch : git rev-parse --abbrev-ref ${the_remote}/HEAD |
Err... But there may be multiple remotes. |
Indeed, I suggest the following approach
|
It seems too complex to me, which may introduce strange behavior. For example, the git-extras in my local machine has two remotes:
The The guess can't guarantee it's 100% correct. @hyperupcall @vanpipy |
@spacewander I think it would be simple and effective to skip the deletion of branches with hardcoded values of We can also read the config value for the default init branch and add that.
I agree with @spacewander, although it is a good heuristic, I think there is too much uncertainty around it and it will invariably do different things, even on the same computer. I for one, always use Another idea is to loop over all remotes, and add any of their default branches to the ignore list. I am not completely certain that it will not introduce many false positives. |
When running
git delete-merged-branches
on a non default branch, it currently deletes the default branch:It's not a big issue, as it can be recovered by switching to master again, looking at the ref log if needed. But this might be something to fix.
It's possible to get the default branch of the remote named
origin
If the remote are not named
origin
this could failAnd not all remote have a default branch
The text was updated successfully, but these errors were encountered: