altsem / gitu

A TUI Git client inspired by Magit
MIT License
1.7k stars 88 forks source link

Feature request: create branch on origin when pushing new branch #90

Open mattgallagher92 opened 4 months ago

mattgallagher92 commented 4 months ago

Thanks for sharing gitu, I love it so far!

When I'm working on a branch that only exists in my local repo and use Magit to push, Magit handles creating the new branch at the destination and setting that branch as the upstream of my local branch. I'd like gitu to do the same.

mattgallagher92 commented 4 months ago

Title should probably say "on remote" rather than "on origin"

altsem commented 4 months ago

Could be the start of #58

rynoV commented 4 months ago

Yeah I think this will be a good starting point, I also find this feature useful

golden-expiriensu commented 4 months ago

@mattgallagher92 You probably want to add

[push]
    autoSetupRemote = true

to your ~/.gitconfig so git will always create a new branch on remote when pushing

mattgallagher92 commented 4 months ago

Thanks @golden-expiriensu! That doesn't quite seem to do what I wanted. However, that prompted me to look through the docs more closely, and setting push.default to current gives me the behaviour that I want :grin: I can then just run a git push (either directly or via gitu) and the branch is created on origin.

@altsem given that this seems to be behaviour that's configurable within Git, gitu should probably respect the Git config. Perhaps that means that there's no need for gitu to change its behaviour (up to you).

An easier solution could be to document Git config in a "Migrating from Magit" section somewhere. I'd be happy to contribute a README PR.

What course of action do you think is best?

altsem commented 4 months ago

Magit does give you a prompt I believe instead of just outright failing, I still think there's value in that!

https://magit.vc/manual/magit/The-Two-Remotes.html

altsem commented 4 months ago

@mattgallagher92 Im still thinking that Gitu could use a user guide. Haven't decided much on how it should look like. But perhaps it's just a matter of giving the README some structure and adding some tips & tricks (like this one).

Feel free to open a PR if you like. I'm open to ideas! :)

edit: I made a simple note in the README with a link to push.default.

mattgallagher92 commented 3 months ago

Sorry for the delay! The README is great 🙂 happy for you to close this unless you think that there's anything else of value being tracked here

mattgallagher92 commented 3 months ago

P.S. gitu is really coming on in leaps and strides - thanks! I'm so pleased that it exists 😁

altsem commented 3 months ago

Magit does give you a prompt I believe instead of just outright failing, I still think there's value in that!

https://magit.vc/manual/magit/The-Two-Remotes.html

Think this is left just.