I want to create a script name git-as which is basically an alias for calling git with a bunch of pre-defined parameters.
git --git-dir="$1/.git" --work-tree="$1/" <<OTHER PARAMS>>
When I want to call git in another repository, I use:
git-as "$SRC_REPO" commit -m "Changes made to $CLASS_NAME"
How do I get the “other params” bit working properly?
Keep in mind, I don’t want the $1 param (containing the repository location) to be passed to git. Also, the other parameters may include double quotes such as the example shows them used.
In bash (but not all other shells), you can use a variant on array slicing to pick out some of the arguments without having
shiftthe others first: