허허의 오늘은 뭐 먹지?
[GIT] WGET으로 특정 Github 파일 가져오기 본문
Github에 commit되어 있는 특정 tar 파일을 다운로드 받기 위해서
wget [url] 명령어로 다운로드를 시도해보았습니다.
url은 해당 파일 소스를 보는 화면의 url을 넣어주었습니다.
다운로드받은 파일의 압축을 풀려고 하는대... 아래와 같은 메세지가 나오고 있었습니다.
"tar: Error opening archive: Unrecognized archive format"
해당 화면의 주소를 볼 것이 아니라 해당 소스의 Raw버튼에 연결되어 있는 주소를 url로 사용해야 정상적으로 tar파일을 다운로드 받을 수 있습니다. Raw버튼을 눌렀을 때 redirect되는 주소는 개발자도구의 Request URL을 참고하면 됩니다.
RAW버튼을 누를 때 개발자도구에서 Redirect되는 주소입니다.
github의 도메인과 다릅니다.
왜 그럴까요?
The general problem is that github typically serves up an html page that includes the file specified along with context and operations you can perform on it, not the raw file specified. Tools like wget and curl will just save what they're given by the web server, so you need to find a way to ask the web server, github, to send you a raw file rather than an html wrapper. This is true whether you use -o -O or >>. The "...//raw.git..." address in this particular test case is probably serving raw files, and pre-solving the OP's problem as posted, which is why all of these answers work, but don't solve the more generic problem. I can download a text file, or an html-wrapped version of it from the following urls. Note the differences between them and feel free to paste them in a new tab or new window in your browser as well.
출처 : unix.stackexchange.com/questions/228412/how-to-wget-a-github-file
how to wget a github file
For example, there is a file here that I want to download via CLI: https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.1.y/arch/arm/configs/bcmrpi_defconfig How to I download the actual file...
unix.stackexchange.com
결론 : wget으로 github의 소스 파일을 가지고 올 때 raw파일을 다운로드 받을 수 있는 url을 지정해 주어야 한다.
'SW > 메모' 카테고리의 다른 글
[GIT] git pull시 Enter passphrase for key 오류 (0) | 2023.04.28 |
---|---|
[python] python decorator (0) | 2023.02.04 |
[Android] DataBinding 오류 찾기 (0) | 2022.07.23 |
[gradle] 맥에서 Gradle 설치하기 (0) | 2022.07.23 |
FaaS(Function-as-a-Service)란? (0) | 2021.04.26 |