Search code examples
gitgithubnpmgithub-cli

Git Clone - Download the repository without keeping git


I want to bring a couple of plugins into WP and make a script that just fetches them from github within an NPM script.

"installplugins": "cd ../../ && 
rm -r mu-plugins && mkdir mu-plugins && 
gh repo clone repo1 mu-plugins && 
gh repo clone repo2 mu-plugins && 
gh repo clone repo3 mu-plugins && 
gh repo clone repo4 mu-plugins && 
gh repo clone repo5 mu-plugins && 
gh repo clone repo6 mu-plugins"

Thing is, right at the second git repo clone, it breaks because you the mu-plugins folder is not empty anymore.

Really, at the end of the day I only need to export the git repo and put it in the folder, without keeping all the git bells and whistles, but I cant seem to find the combination of flags needed to do a repo download instead of a classic repo clone.

Anybody can help me on that?


Solution

  • Ideally, you would clone them in their own folder.

    gh repo clone repo1 mu-plugins/repo1
    gh repo clone repo1 mu-plugins/repo2
    gh repo clone repo1 mu-plugins/repo3
    

    But if you need all the repo files in mu-plugins, you would:

    • clone those repositories in a separate folder
    • go to mu-plugins (assuming a git init . done in it)
    • add the files of each of those repos

    That is:

    cd mu-plugins
    git work-tree=../aFolder/repo1 add .
    git commit -m "Import repo1 content"
    ...