nvie / git-toolbelt

A suite of useful Git commands that aid with scripting or every day command line usage
BSD 3-Clause "New" or "Revised" License
1.25k stars 111 forks source link

Git cleanup by default removes remote branches #54

Closed guiccbr closed 2 years ago

guiccbr commented 3 years ago

I was surprised that after running cleanup (without reading the docs carefully), all of the merged branches were also removed in the remote. Even branches that were not created by me.

It seems to me that the default should be local-only to make sure that we don't mess up with branches that other devs may be relying on.

nvie commented 3 years ago

Yeah, that is a good point. If you feel like adding a flag for that (perhaps -r?), I'd be happy to merge that in! 🙏

guiccbr commented 3 years ago

Tks, @nvie , there is already a flag-l, that has the opposite behavior. Do you think that it's ok to rename it to -r and make the adjustments? If so I can send a pr.

nvie commented 3 years ago

I wouldn't mind making them both explicit, so that just invoking git cleanup without flags would not do anything and show the usage, and it would ask you to specify -l, -r, or both.

riotrah commented 2 years ago

+1 on this very much! I just deleted a ton of remote branches by making this assumption/mistake, though I recognize it's on me to keep this sort of thing in mind.

I see no PR referenced in this issue, shall I take this on?

riotrah commented 2 years ago

Another thought though - how hard might it be to make a variant/default that only deletes your branches remotely, instead of any?

nvie commented 2 years ago

Thanks for the ping, @riotrah! I just implemented the behavior I suggested earlier, which I've released as v1.8.0 just now.