My team uses a format for our branch names for uniformity. For a given branch, the format would be: "feature/TeamName-CardNumber". The card number is the only part of this that will change, so I would like to make an alias such as:
git cobf '111'
Where 111 is the card number.
I tried this command to set the alias:
git config --global alias.cobf 'checkout -b feature/TeamName-"
But when running the git cobf 111
command, I get an error saying that 111 is not a commit and a branch cannot be created from it.
Why does it fail?
It's because after expansion of the alias, your command is resolved as
...which to git means "checkout a new branch named
feature/TeamName-
pointing at committish111
" (roughly put, "committish" is something that is either a commit or something pointing at one, like a branch or tag)What to do instead?
To avoid that, use an ad-hoc bash function to handle parameters more conveniently :
Note : the quotes are unneeded when you'll call the alias,
git cobf 111
will do.