1

Is there a method to directly do cloning via the REST v3 Github API? Is the best way to create a new repo via the API, get the content of the one you want, and do a PUT request to the new repo with that content? Does that method even work?

I want to clone a GitHub repository into an arbitrarily named repository on my own account without support from the git CLI or GitHub UI (i.e. using GitHub Actions programmatically to automatically provision the repository). What are some thoughts on the best way to do this?

PeterZhu
  • 11
  • 1
  • 2

1 Answers1

3

tl;dr There isn't a way to "clone" via API's.

I'm also looking to do something similar, here are some workarounds I've found:

  1. You can hit the repo api and get the clone url and manually clone. You won't be able to clone via the API, however.

  2. Use the content api. This will get you a link to download each file, and a url to get the tree of each folder. You'll have to traverse this and manually download each file. This might be optimal for individual files, not the whole repo.

  3. You can also download the entire repository. This might be optimal for getting the entire repo.

ladder
  • 189
  • 2
  • 9