0

Currently my git aliases all have to depend on the arguments being passed in a specific order, accessing them with $1, $2, etc.

What I would want to do is something like

git sync --from="dev" --to="uat"

Where sync is the alias where I would want to access the values of $from and $to

Is this possible in some way?

EDIT - This is not a question of how to use existing git commands with named parameters in aliases. I'm already using the "sync = !sh -c '<bunch of commands here>'" format to handle this. I want to create my own custom parameters for my aliases so I don't have to use $1, $2, $3 in my script.

Valyrion
  • 2,342
  • 9
  • 29
  • 60
  • 1
    Possible duplicate of [Git alias with positional parameters](https://stackoverflow.com/questions/3321492/git-alias-with-positional-parameters) – zigarn Jun 29 '17 at 11:56

1 Answers1

1

As you've no doubt noticed, the alias functionality doesn't support named parameters. The best you can do, then, is to write your "bunch of commands" into a script that also parses the command line.

So if we recast the quesiton as, how do I parse command line arguments in a shell script, you can find some help here: How do I parse command line arguments in Bash?

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52