Search code examples
gitgithubpygithub

How can I download a git branch without using git command


I have a private repo and I want to download a branch files from it. My environment doesn't have the git command installed. It would be great if I can do this with Python/PyGithub


Solution

  • Your repo is on github, right ?

    Through the GUI : when you view the content of a file, you can see a Raw button on the top right part of the file view.

    This points you to a url, which will give you the raw content of said file.

    Here is an example :

    You simply have to download this file, e.g :

    curl https://raw.githubusercontent.com/golang/go/master/README.md
    

    For a file in a private repo, you will need to also pass some credentials.