- How Do You Download From Github For Beginners
- How Do You Download From Github For Windows
- How Do You Download From Github Windows 10
- How To Download From Github Command Line
How to clone, modify, add, and delete files in Git. Say you already have a Git repo on GitHub and you want to get your files from it—maybe you lost the local copy on your computer or you're working on a different computer and want access to the files in your repository. What should you do? Download your files from GitHub?
I wrote this article here about setting up GitHub in Visual Studio 2015 and felt it necessary to document the same in Visual Studio 2017. Here is how I setup GitHub source code management in Visual Studio 2017 Community.
- Install the GitHub extension for Visual Studio
- Create your GitHub repo and then login
- Create a GitHub repository
- Create a project for the repository
- Add the source code to GitHub
Check out these 2 articles about including 4.6.2 and C# 7 capabilities into Visual Studio 2017, also discussed later on.
NOTE: After completing this configuration, I did not find any difference between the GitHub setup in Visual Studio 2015 and Visual Studio 2017, they work both the same.
In Visual Studio select Tools -> Extensions and Updates which open the window show in Figure 1. Download and install the extension, a reboot of Visual Studio was required for me.
Figure 1, GitHub for Visual Studio
If you do not already have an account on GitHub then you need to create on. Create it and then come back to this point. Once created, use the credentials to login to your GitHub account, as shown in Figure 2.
Figure 2, login to GitHub from Visual Studio
Now create GitHub repository by selecting the Create button on the Team Explorer tab in Visual Studio, as show in Figure 3.
Figure 3, create a GitHub repository from Visual Studio for Visual Studio
When you click on the Create link, a window similar to that shown in Figure 4 is rendered. Enter the name of the repository, a description and the local location where you would like to store the source code. I use the default.
Figure 4, create a GitHub repo using Visual Studio
After clicking on the Create button shown in Figure 4 and once the repository is created locally, you are prompted to create a Project to store into it. Similar to that shown in Figure 5.
Figure 5, create a project to store in GitHub from Visual Studio
For this example, I am creating an ASP.NET Core Web Application using .NET 4.6.2 (the newest at the time of this blogs creation) which also supports Web API calls, JIC I decide to add some troubleshooting of WEB APIs later. Check out these 2 articles about including 4.6.2 and C# 7 capabilities into Visual Studio 2017.
As seen in Figure 6, I select an ASP.NET Core Web Application and on the next windows I select ASP.NET Core 1.1 and Web Application.
Figure 6, create a project for GitHub from Visual Studio
Once the project is created, click on the Team Explorer tab, and expand the Project tree. Click on the Changes button as shown in Figure 7.
Figure 7, commit changes to the GitHub repo using Visual Studio
Clicking on the Changes button navigates to the page shown in Figure 8. Enter a description and press the Commit button, as shown in Figure 8.
Figure 8, commit the initial project to GitHub from Visual Studio
Once committed, synchronize the locally committed source code to the public source hosted on GitHub. As seen in Figure 9, after the commit is complete, you are requested to Sync the changes using the Sync link. You can also Sync them at a later time by clicking the Sync button shown previously in Figure 7.
Figure 9, synchronize code with GitHub from Visual Studio
On the Synchronization page, click the Push link to synchronize the changes, as shown in Figure 10
Figure 10, Push the code from a local GitHub to a public GitHub using Visual Studio
Once complete, you can see the code is public on the GitHub site using a browser, as seen in Figure 11.
Figure 11, viewing the source on GitHub
curl --header 'Authorization: token INSERTACCESSTOKENHERE' |
--header 'Accept: application/vnd.github.v3.raw' |
--remote-name |
--location https://api.github.com/repos/owner/repo/contents/path |
# Example... |
TOKEN='INSERTACCESSTOKENHERE' |
OWNER='BBC-News' |
REPO='responsive-news' |
PATH='scripts/build/tabloid.sh' |
FILE='https://api.github.com/repos/$OWNER/$REPO/contents/$PATH' |
curl --header 'Authorization: token $TOKEN' |
--header 'Accept: application/vnd.github.v3.raw' |
--remote-name |
--location $FILE |
commented Feb 11, 2015
Hey! This is pretty cool. Do you know if there is a way to download a file from a specific branch? |
commented Feb 11, 2015
nevermind, just found the docs https://developer.github.com/v3/repos/contents/ |
commented Apr 7, 2015
You should use another name for the PATH variable because it would obviously overwrite the system PATH variable and even make the curl command not to be found. |
commented Sep 17, 2015
Instead of single quote marks, |
commented Oct 27, 2015
commented Dec 11, 2015
Is there a way to do the same thing without authorization? |
commented Mar 8, 2016
How Do You Download From Github For Beginners
this only works on files <1mb unfortunately.. but if that's not an issue for you it's useful |
commented Jun 14, 2016
Just as a note, the remote-name parameter can append the ref parameter if present. I haven't found a good workaround to this |
commented Jun 20, 2016 • edited
edited
Great script! If you download files from private GitHub repos often, you can also check out fetch, an open source, cross-platform tool which makes it easy to download source files and release assets from a git tag, commit, or branch of public and private GitHub repos. For example, to download the file |
commented Jul 20, 2016
does this also work for github enterprise? |
commented Aug 8, 2016
fetch doesn't work for the URL with subdomain like 'github.example.com' |
commented Aug 16, 2016
Any idea why I am not able to run this? I am getting below error |
commented Aug 18, 2016
@mdtareque did you override your PATH env variable perhaps? |
commented Oct 17, 2016
Hi, @mdtareque: The |
commented Feb 6, 2017
Ref rem7's comment about the ref parameter for downloading from a specific branch, I'm struggling to work out how to integrate this into the curl.sh shell script. Can anyone provide an example? |
commented Apr 10, 2017 • edited
edited
Just add FILE='https://api.github.com/repos/$OWNER/$REPO/contents/$PATH?ref=a-different-branch |
commented Jun 4, 2017
I am getting below message when trying to access a private repo. curl -H 'Authorization: token TOKEN' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/mkarthik415/repo/blob/master/AppManager/AppManager/maven-metadata-local.xml |
commented Aug 9, 2017
Just one comment: rename PATH to another variable name, since PATH is a special variable in Linux Console. You may get 'command not found' after setting PATH used in the example. |
commented Aug 23, 2017
I would like to download a file from a private repo which I am a member, is it possible I can use the download link to download the file from a browser? I tried it without an error message, but failed to download the file. BTW, I already logged into my Github account from the browser. Thanks |
commented Oct 25, 2017
How Do You Download From Github For Windows
+1 to renaming PATH |
How Do You Download From Github Windows 10
commented Nov 5, 2017
Is there a way that doesn't utilize the GitHub API? |
commented Feb 1, 2018 • edited
edited
Github enforces usage of a valid If you are making the same request multiple times, include a |
commented Sep 10, 2018
How can I download the entire repository from GitHub any idea, please?? |
commented Sep 11, 2018 • edited
edited
commented Oct 3, 2018
+1 Rename $PATH |
commented Oct 12, 2018 • edited
edited
Note that this endpoint is limited to 1 MB files. any larger will fail. working on a workaround |
How To Download From Github Command Line
commented Oct 16, 2018 • edited
edited
I have found a workaround for large files (up to 100 MB but as far as I know it is not possible to drop larger files to github so this should work with all files) the contents endpoint used above cannot get the file if larger than 1 MB so trim the $PATH to direct to the folder where your file lies in the initial request using the contents endpoint In the response, find your file listed, get its SHA, use the For reference, see the R code below |