Search code examples
gitgitlabgit-config

How do you add gitconfig clone functionality to pull the project and wiki in gitlab?


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)' -

Solution

  • 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.