lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Allow pushing with only remote, no branch name

Open spencerpogo opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe. I often set up my git repos with an origin remote and an additional fork remote. Then, when I want to make a PR, I can fork off a new branch, commit, then run git push fork. Git will then automatically push my current branch. In lazygit (0.42.0), bringing up the push panel and deleting the branch name will come up with the error: Invalid upstream. Must be in the format '<remote> <branchname>'

Describe the solution you'd like Update the matching conditions for a valid push target

spencerpogo avatar Jul 09 '24 01:07 spencerpogo

Under which name does git push fork push the branch?

E.g. if you are on a branch performance_fix and do git push fork?

mark2185 avatar Jul 09 '24 04:07 mark2185

It will push to whatever the upstream is set to for the current branch. You can check it with git branch -vv: SO link I can't figure out why, I think this got set for me automatically the last couple times I used it while working.

spencerpogo avatar Jul 09 '24 04:07 spencerpogo

It will push to whatever the upstream is set to for the current branch. You can check it with git branch -vv: SO link

That's probably dictated by your global gitconfig.

And you want to push it under the same name, i.e. performance_fix to the upstream fork? If so, why delete the name from lazygit's push prompt?

mark2185 avatar Jul 09 '24 05:07 mark2185

And you want to push it under the same name,

yes

why delete the name from lazygit's push prompt?

Because you need to delete it in order to move the cursor to the remote, so you change it from origin to fork.

spencerpogo avatar Jul 09 '24 05:07 spencerpogo

Ah, now I get it.

For the time being, you can press ctrl+a to jump to the beginning of the line and use delete to delete the origin part and replace it with fork.

mark2185 avatar Jul 09 '24 06:07 mark2185

Or use alt-left-arrow to jump over the branch name, and ctrl-w to delete the remote name and type another one.

These keybindings work in all of lazygit's text fields, it is useful to get used to them. I use them in the commit message panel all the time.

stefanhaller avatar Jul 09 '24 07:07 stefanhaller

These keybinds don't seem to work on my system: Alt-left-arrow just adds [1;3D to the text for me, and ctrl+w has no effect. Probably my fault (I run a very niche distro, NixOS), but up until now I just figured lazygit didn't bother adding readline or whatever to the textboxes.

spencerpogo avatar Jul 09 '24 18:07 spencerpogo