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

automatic track for non-existing local branches #50

Open
mdedonno1337 opened this issue Mar 6, 2021 · 3 comments
Open

automatic track for non-existing local branches #50

mdedonno1337 opened this issue Mar 6, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@mdedonno1337
Copy link
Contributor

mdedonno1337 commented Mar 6, 2021

How about add an option to allows automatic tracking for new branches if not available locally?

I know it's possible to track the branch with the 'alt-enter' binding; if forgotten, we go to the detached head situation.
I think an option to automatically create the branch and track it could be interessting; this behaviour would be disabled by default, to not break current behaviour.

I can git it a try and do the PR.

@mdedonno1337 mdedonno1337 changed the title automatic track automatic track for non-existing local branches Mar 6, 2021
@stsewd
Copy link
Owner

stsewd commented Mar 11, 2021

Sure, I wanted to implement this a time ago, but didn't end with a solution that always worked for all cases.

@stsewd stsewd added the enhancement New feature or request label Mar 11, 2021
@mdedonno1337
Copy link
Contributor Author

I will give it a try.

@Grueslayer
Copy link

Here my tow pence:

with

git branch --format "%(refname:short)|%(upstream:short)"

you'll get a list of branches with its possible upstream.

  1. Test if you have chosen a local repo (refname = name) => {branch} = refname, {localbranch} = refname, {remotebranch} = upstream
  2. Test if you have chosen a remote repo with local copy (upstream = name) => {branch} = refname, {localbranch} = refname, {remotebranch} = upstream
  3. Otherwise its a remote only => {branch} = chosen name, {localbranch} = empty, {remotebranch} = chosen name

Now you are able in VIML to code somtehing like this

  1. if {localbranch} != '' then system("git switch {localbranch}")
  2. else system("git checkout --track {remotebranch}")

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

3 participants