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

gco fails when the branch name contains - #47

Open
danberindei opened this issue Jun 28, 2021 · 2 comments
Open

gco fails when the branch name contains - #47

danberindei opened this issue Jun 28, 2021 · 2 comments
Labels

Comments

@danberindei
Copy link

I use the JIRA issue id (e.g. ISPN-12345) as a prefix for all my task branches, and gco ISPN-12345_task fails:

Invalid argument: 'ISPN'
~/.config/fish/functions/gco.fish (line 46):
if [ $first -lt $last ]
^
in function '__gco' with arguments 'ISPN-12345_task'
called on line 75 of file ~/.config/fish/functions/gco.fish
in function 'gco' with arguments 'ISPN-12345_task'
Argument is not valid.

@bingocaller
Copy link
Contributor

Hi @danberindei, thank you for raising this issue!

The gco function also supports branch names with hyphens, but it doesn't detect them automatically. You can enable support for hyphened branch names by un-commenting line 27. However, this will disable the ability to pass in ranges of numbers, like gco 1-5.

What I usually do instead is run gb first and then use the assigned number to gco the branch I want. This also works for branches with hyphened names.
Another alternative is to use git checkout directly when switching branches; tab-completion works for that, plus you could even create an abbreviation for it like abbr -a gch 'git checkout' (that's what I did) to make things even easier.

@shinriyo shinriyo added the bug label Jun 28, 2021
@danberindei
Copy link
Author

Thanks @bingocaller!

I didn't follow up the issue because I ended up using git switch for more branch-related stuff (aliased to gw).
gb has the same issue and it's a bit annoying when I want to rename a branch and automatically type gb -m new-name, but I use that a lot less often so it's not too bad.

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

No branches or pull requests

3 participants