jesseduffield / lazygit

simple terminal UI for git commands
MIT License
47.94k stars 1.72k forks source link

New branch track upstream is the same as the branch that did the checkout from #3675

Open gabriGutiz opened 2 weeks ago

gabriGutiz commented 2 weeks ago

Describe the bug When creating a new branch from a remote one, the new branch remote track is the same as the old one.

To Reproduce Steps to reproduce the behavior:

  1. Go to Remote branch panel
  2. Hit 'n' to checkout
  3. Choose a name with the same 'feature/' prefix
  4. Hit 'P' to push origin
  5. Pushes to the old branch

Expected behavior When pushing to the new branch, should ask the remote upstream branch instead of pushing to the old branch.

Screenshots image

For context: feature/CAN-4068 is the remote branch I did the checkout from.

Version info: commit=6fcb7eb8bb616c170506312870b3bf15f3dbe37c, build date=2024-05-19T10:15:28Z, build source=binaryRelease, version=0.42.0, os=windows, arch=amd64, git version=2.45.0.windows.1 git version 2.45.0.windows.1

mark2185 commented 2 weeks ago

You can unset the upstream from the menu under u.

The default behavior is that the local branch tracks the upstream, which is nifty for most use cases.

gabriGutiz commented 2 weeks ago

I was able to change the upstream, but in my case makes more sense to not set the upstream. I want to make a task based on a teammate's change without changing his branch.

Is that a way to change this default behavior locally?

stefanhaller commented 2 weeks ago

I think I would be fine with changing the n command to not automatically track the remote branch. I find it unlikely that people want to create a branch with a different name that still tracks the remote branch; and for creating a branch with the same name that tracks the remote branch, they can use space instead.

@gabriGutiz In the meantime, a workaround is to hit enter on the remote branch to see its commits, and then hit n on the head commit; this will create a local branch that doesn't track anything.

gabriGutiz commented 2 weeks ago

Thanks, @stefanhaller! I'll use this workaround so on.

Just adding that I agree with what you said, It's a little annoying that I have to delete the upstream to not make a mess by mistake or do what you described!

Thanks for the attention!!

jesseduffield commented 1 week ago

I think I would be fine with changing the n command to not automatically track the remote branch. I find it unlikely that people want to create a branch with a different name that still tracks the remote branch; and for creating a branch with the same name that tracks the remote branch, they can use space instead.

I agree