Reputation: 447
I have documentation that requires updating in XXX project and, when cloned, I need to also clone the wiki so the documentation can be updated.
So I'm trying to add a clone alias to clone both the XXX and XXX.wiki projects, but that hasn't yielded positive results. Does anyone have a suggestion that might better solve my problem?
I've included this to show one of my many trials, but it in no way reflects the breadth of my attempts.
[alias]
cl = !sh -c 'git clone [email protected]/$1 $(basename $1)' -
Upvotes: 1
Views: 153
Reputation: 12221
This is quite difficult to do with an alias, because Git does strange things with parameters your provide to an alias, which I could not figure out.
However, you can also define a command by creating a script with the right name. git cl
will invoke git-cl
if it finds it on your path, and it's a lots easier to solve your problem in a bash script.
So, add a file called git-cl
to your path, say, in ~/bin
:
#!/bin/bash
git clone [email protected]/$1
git clone [email protected]/$1.wiki
Run chmod +x ~/bin/git-cl
And then this should work: git cl XXX
will clone both XXX and XXX.wiki into your current folder. Adjust the exact commands run in git-cl
to meet your needs if I didn't get them quite right.
Upvotes: 2
Reputation: 141000
but I'm not certain how to construct that
You can do a function, it's specially handled by git-alias
code.
[alias]
cl = "!f() { git clone this/\"$1\"; git clone that/\"$1\"; } f"
And you can create a file named git-cl
with the content:
#!/bin/sh
git clone this/"$1"
git clone that/"$2"
and add this file executable permissions and add it to PATH
. git will automatically pick it up when typing git cl
.
Upvotes: 3