Copy the specific file's raw link from GitHub.(As you open the file in Github, on the top right corner you can see the option to open the file in raw mode. Open it in raw mode and copy the URL)
Now use curl or wget command in command line to download the file.
curl -o filename raw-link-to-file
or
wget -O filename raw-link-to-file
Please note that
Answer from mental_matrix on Stack OverflowCopy the specific file's raw link from GitHub.(As you open the file in Github, on the top right corner you can see the option to open the file in raw mode. Open it in raw mode and copy the URL)
Now use curl or wget command in command line to download the file.
curl -o filename raw-link-to-file
or
wget -O filename raw-link-to-file
Please note that
If you go to the page and view the links provided by "raw" (in the top left corner, when viewing the file). You will see, that you can access it by:
https://github.com/username/repository/raw/$changeset_hash/path/to/file
Instead of $changeset_hash you can also provide a branch (e.g. master) or tag.
You can retrieve the raw file using something like wget.
Accessing a single file directly from a .git-repository is not possible (as far as I know), because of how the data is stored.
edit: When you want to access a file from a private repo, you first have to create an access token with the appropriate permissions in your account settings. Instead of calling the url above you can then use github's API to access the content of a file. Be sure to use the Accept-header for custom media types to get the raw data. This might look something like this:
curl \
-H 'Authorization: token $YOUR_TOKEN' \
-H 'Accept: application/vnd.github.v3.raw' \
-O \
-L 'https://api.github.com/repos/:owner/:repo/contents/:path'
The -O will save the contents in a local file with the same name as the remote file name. For easier use you can wrap it in a script. @Chris_Withers suggested an edit with a nice python snippet that unfortunately got rejected as to big of a change to the answer.
git - Shortest way to download from GitHub - Unix & Linux Stack Exchange
Plain and simple: How to download files from github?
I'm embarrass to ask but how do you download and install stuff from github?
Downloading Stuff from GitHub in Linux Command Line - Tutorials & Resources - It's FOSS Community
The shortest way that seems to be what you want would be git clone https://github.com/user/repository --depth 1 --branch=master ~/dir-name. This will only copy the master branch, it will copy as little extra information as possible, and it will store it in ~/dir-name.
This will clone the files into new directory it creates:
git clone [email protected]:whatever NonExistentNewFolderName
It does work, if you use the correct URL.
For a GitHub repo, there's a zip at https://github.com/<user>/<repo>/archive/<branch>.zip, so you can download it with:
wget https://github.com/<user>/<repo>/archive/<branch>.zip
This downloads the zipped repo for a given branch. Note that you can also replace the branch by a commit hash.
Using cURL
curl -L -O https://github.com/<user>/<repo>/archive/<branch>.zip
cURL's -L flag follows redirects - it's a default in wget. -O is advised by Phil Gibbins in a comment.
Download a .tgz instead of .zip
You can also download a tarball with:
wget https://github.com/<user>/<repo>/archive/<branch>.tar.gz
From the comments I saw you actually speak about GitHub.
It won't work like this because:
Downloading a project on GitHub causes the GitHub server to first pack your project as zip and than forwarding you to a temporary link where you get your zip ..
this link will only work for a certain time and than GitHub will delete your zip file from their servers..
So what you get with wget is just the html page which would forward you as soon as your zip file is generated.
As suggested use
git clone http://github.com/<yourRepoLink> <optional local path where to store>
to download the git repo ... If for some reason (e.g. for transfer it to others) you need it explicitly as zip you still could pack it after cloning is finished..
I found this sub after angrily searching for this question on google. I found a post about a person asking to learn about github and still, zero comments about how to download stuff. I've been trying and looking for an answer by myself, with google, but failed at least 3 times in the last 6 years. This time my blood boiled in anger and frustration too much and I gave up on my self-learning principles to ask reddit for help. Can you (of course you can) help me?!
PS: sorry for my bad english. I learnt by my own principles.
PS2: Best Playstation games
PS3: You can call me names and make fun of my noobiness and bully me all you want. I, non ironically, love verbal aggression!
First of all, curl says "bad/illegal format" because you're mixing the URL-style and rsh-style address formats. Traditionally, Git accepts both for git clone, but only the latter puts a : between host and path – whereas in URLs, all paths start with a /. For example, the rsh/scp-style address [email protected]:foo/bar would be written as the URL ssh://[email protected]/foo/bar, just like HTTP URLs.
SSH is not a file transfer protocol on its own – it's more like TLS, something that can carry various file transfer protocols such as SFTP or scp or rsync (much like TLS can carry HTTP). Giving curl an ssh:// URL is meaningless1, but you could give it an sftp:// one to retrieve a file over SFTP. (Note how the article that you linked also specifically uses SFTP.)
However, GitHub does not provide SFTP access; the only thing allowed over SSH connections to GitHub is the Git protocol. That's not something you can access with curl, only with git clone.
So if you must use SSH, then your only option with GitHub is to actually clone the repository via Git. (It is possible to reduce the download size using --depth= or --filter= options, but it still ends up being a whole repository and not just the individual file.)
1 (Git uses ssh:// URLs but the meaning is clear from context – it's the Git protocol, but tunnelled over SSH. Git doesn't use SFTP.)
first of all you need a API access token from github how to create it:
- go to github.com and click on your profile picture at top right
- scroll down and click settings on the side bar which is shown
- scroll down and click on developer settings on left sidebar
- click on Personal Access Token(menu bar)
- click on tokens(classic)
- then click on Generate New Token(menu bar)
- then click on generate new token(classic)
- write the information of the token(name, expires date) and be careful! allow all of the access which is shown on the page! if you don't the API shouldn't work
- copy your API key
- write this code with the token you got copy
import requests
from requests.structures import CaseInsensitiveDict
GH_PREFIX = "https://raw.githubusercontent.com"
ORG = "GITHUB_USERNAME"
REPO = "YOUR_REPOSITORY_NAME"
BRANCH = "YOUR_REPOSITORY_BRANCH"
FOLDER = "THE_FOLDER_WHICH_INCLUDE_TEST.txt"
FILE = "THE_FILE_YOU_WANT_TO_ACCESS(TEST.txt)"
url = GH_PREFIX + "/" + ORG + "/" + REPO + "/" + BRANCH + "/" + FOLDER + "/" + FILE
headers = CaseInsensitiveDict()
headers["Authorization"] = "token " + "YOUR_API_ACCESS_TOKEN_HERE"
r = requests.get(url, headers=headers, stream=True)
first = str(r.content).replace("b'", "")
second = first.replace("\\r", "")
third = second.replace("\\n'", "")
result = third.replace("'", "")
print(result)
i hope this helps you
I'm not used to arch because it's my first time. I am trying to install a bunch of emulators on my laptop. The discover app is not working and it can't download anything. I did use the terminal and I was able to download emulators like dolphin, ppsspp, desmume and mgba. The 3ds and playstation 1-3 are the ones left, and they're in github. Also what are the commands on the terminal if you want to delete all of the file?
Edit* thanks y'all
Wget for Windows should work.
From the Wget Wiki FAQ:
GNU Wget is a free network utility to retrieve files from the World Wide Web using HTTP and FTP, the two most widely used Internet protocols. It works non-interactively, thus enabling work in the background, after having logged off.
From this section of FAQ, download links are suggested:
Windows Binaries
courtesy of Jernej Simončič: http://eternallybored.org/misc/wget/
from sourceforge: http://gnuwin32.sourceforge.net/packages/wget.htm
[...]
Link with courtesy of Jernej Simončič is used instead.
An alternative I discovered recently, using PowerShell:
$client = new-object System.Net.WebClient
$client.DownloadFile("http://www.xyz.net/file.txt","C:\tmp\file.txt")
It works as well with GET queries.
If you need to specify credentials to download the file, add the following line in between:
$client.Credentials = Get-Credential
A standard windows credentials prompt will pop up. The credentials you enter there will be used to download the file. You only need to do this once for all the time you will be using the $client object.