github

download single file from GitHub repository

from a public repository using the command line and renaming file

This example grabs the Node.gitignore file from GitHub’s gitignore repository, downloads it to your current working directory and renames it to .gitignore - all very typical actions for someone starting a new node.js project.

$ curl https://github.com/github/gitignore/raw/master/Node.gitignore -o .gitignore

find the url of the file you want to download

  1. navigate to the desired file in a repository
  2. click the ‘raw’ button
  3. copy the url from the address bar

See the following example from GitHub’s gitignore repository: https://github.com/github/gitignore/raw/master/Node.gitignore

You can quickly recognize a url that will work to download an individual file vs downloading the html page. Look for the subdirectory /raw/ right before the branch name.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow