Skip to content
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

Add option to delete remote branch when deleting local branch #2157

Closed
kadaan opened this issue Sep 7, 2022 · 3 comments
Closed

Add option to delete remote branch when deleting local branch #2157

kadaan opened this issue Sep 7, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@kadaan
Copy link

kadaan commented Sep 7, 2022

Is your feature request related to a problem? Please describe.
Add option to delete remote branch when deleting local branch

Describe the solution you'd like
After confirming the deletion of a local branch, off the user the ability to delete the remote branch

Describe alternatives you've considered
Manually deleting both the local and remote branch

Additional context
Add any other context or screenshots about the feature request here.

@kadaan kadaan added the enhancement New feature or request label Sep 7, 2022
@mark2185
Copy link
Collaborator

mark2185 commented Sep 8, 2022

To quote Jesse:

This could also be a good candidate for a pre-set custom command. See https://github.com/jesseduffield/lazygit/wiki/Custom-Commands-Compendium

It's much easier to implement features if a user has created a custom command for it first, because it's clearer what the expected behaviour is.

You could have something like this to delete the remote branch, and then delete the local one as usual:

  - key: 'D'
    command: 'git push {{ .SelectedLocalBranch.UpstreamRemote }} --delete {{ .SelectedLocalBranch.UpstreamBranch }}'
    context: 'localBranches'
    stream: true

It is a few keystrokes extra, but hey.

If you really want to delete both at once, then this should work as well:

  - key: 'D'
    command: >-
      git push {{ .SelectedLocalBranch.UpstreamRemote }} --delete {{ .SelectedLocalBranch.UpstreamBranch }} &&
      git branch --delete {{ .SelectedLocalBranch.Name }}
    context: 'localBranches'
    stream: true

@louwers
Copy link

louwers commented Sep 30, 2024

How about just adding an option to delete both in one go?

@stefanhaller
Copy link
Collaborator

Yes! This has recently been implemented, see #3916.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants