Как скачать один файл с github
Перейти к содержимому

Как скачать один файл с github

  • автор:

How do I download a particular file from GitHub?

I only need one particular file from a project published on GitHub so it makes little sense to download the whole project. But I just can’t find the download button.

5 Answers 5

If you’re viewing the contents of the file itself there should be a «Raw» button.

get raw

  • Right-click on that and select the «Save content as. » (or similar depending on your browser)
  • Click through to see the contents dumped onto the screen and save from there

In the list of files, every filename is a link. A simple right-click and «Save link as. » (or equivalent for your browser) will allow you to download a single file.

This breaks down with HTML files, however. You’ll need to use the «Raw» button on the file page as Eight Days of Malaise’s answer describes. I’m using Google Chrome. You may have a different experience on a different browser.

Check out RawGit which is a free service to serve files directly from Github with proper Content-type headers.

If you are using the Chromium browser, just hold down the ALT key and left click on the file to download it.

(Doesn’t work with Mozilla Firefox, haven’t tested other browsers.)

theLittleEndian's user avatar

You can try github-files-fetcher, it is a command line tool which downloads a single folder or file from a GitHub repo.

Think a real scenario: you were visiting the following webpage page and wanna download the async subdirectory alone.

How to Download From GitHub: A Beginner’s Guide

Jamie Juviler

GitHub is one of the largest developer resources, and an absolute must-know for aspiring web developers to explore and share projects online.

person using a computer do download from github

If you’re just starting out with git and GitHub, taking open-source code from GitHub to experiment with or add to your own projects is one great way to learn or develop your own apps. You can even connect your GitHub repository to your preferred hosting to deploy and test your apps. To do that, you’ll need to learn the basics: getting a file from GitHub onto your computer.

Download Now: 50 Code Templates [Free Snippets]

50 Free Coding Templates

Free code snippet templates for HTML, CSS, and JavaScript — Plus access to GitHub.

  • Navigation Menus & Breadcrumbs Templates
  • Button Transition Templates
  • CSS Effects Templates
  • And more!

You’re all set!

Click this link to access this resource at any time.

How to Download a GitHub Repository

GitHub is made up of repositories. A repository is a place where all files in a project can be stored, accessed, tracked, and modified. To download a repository, follow these steps:

1. Navigate to the GitHub repository page. If it’s a public repository, you can visit the page without logging in. If it’s a private repository, you’ll need to log in and have the proper permissions to access it.

2. On the main repository page, click the green Code button.

the main github page with the code button circled

3. In the menu that appears, click Download ZIP. The entire repository will be downloaded to your device as a zipped file.

the github download zip button

With that, you should be able to open the file locally.

How to Download a Release From GitHub

Repositories may also put out releases, which are packaged versions of the project. To download a release:

1. Navigate to the GitHub repository page. If it’s a public repository, you can visit the page without logging in. If it’s a private repository, you’ll need to log in and have the proper permissions to access it.

2. Click Releases, located on the right-side panel.

the releases option int he github side panel

3. You’ll be brought to a page listing releases from newest to oldest. Under the release that you want to download, locate the Assets section. Click a file under this section to download it.

assets in the github releases menu

You’ll be able to open this zipped file on your local device.

How to Download Multiple Files From GitHub

Unless you want to download an entire repository or release, there’s currently no way to bulk-download multiple files from GitHub. Depending on how many files you need from a repository, it may be best to download each individual file you need, or download the entire repository/release and delete the files you don’t need.

Get files from GitHub.

There’s a lot to learn when it comes to using GitHub — the platform packs a ton of features, and it can seem intimidating to newcomers. However, GitHub does an excellent job of making its tools simple and accessible. Case in point: downloading a single file or an entire repository is possible with just a few clicks.

New Call-to-action

Dozens of free coding templates you can start using right now.

DOWNLOAD FOR FREE DOWNLOAD FOR FREE

100% Free CRM

Nurture and grow your business with customer relationship management software.

Инструкция: как скачать файл с GitHub

Закройте IDE. Забудьте про пуши. Отрекитесь от коммитов и репозиториев.

Кадр: сериал «Остановись и гори»

Максим Сафронов

Если вы откроете файл в веб-версии GitHub, то заметите, что там нет отдельной кнопки «Скачать». Действительно, удобного способа загружать код напрямую с сайта разработчики не завезли, но есть альтернативные способы — в этой статье как раз о них поговорим. Заодно разберёмся, как скачивать файлы с GitHub на смартфон — пока только на Android-устройства, с айфонами всё сложно.

Способ первый

Скачать проект целиком

Все проекты на GitHub хранятся в репозиториях. Репозиторий — это место, где лежат файлы, библиотеки и фрагменты кода программы. Хорошая новость: если у вас есть доступ к проекту, его можно утащить себе на компьютер и разобрать на отдельные файлы. Вот как это сделать:

Шаг 1. Выберите проект, который хотите скачать. Ваши репозитории хранятся в разделе Your repositories, а проекты из свободного доступа можно найти с помощью окошка Search or jump to.

Шаг 2. Откройте выбранный проект. Мы, например, решили забрать себе классический «виндовый» калькулятор, с недавних пор выложенный в открытый доступ в аккаунте Microsoft.

Шаг 3. Нажмите кнопку Code в правом верхнем углу. Выпадет меню, в котором нужно выбрать Download ZIP.

Готово! Теперь у нас на компьютере есть собственная версия проекта. Можно запустить его в Visual Studio, а также в другом редакторе кода или IDE и допилить под свои нужды. Например, перекрасить кнопки в фиолетовый цвет — а почему бы и нет? ��

Способ второй

Скачать файл с GitHub через Raw

Единственный штатный способ скачать отдельный файл в GitHub — это кнопка Raw. Она превращает код файла в обычный текстовый документ без всякой разметки — в таком виде его можно легко загрузить на жёсткий диск. Не слишком удобный, но рабочий способ — давайте его тоже разберём.

Шаг 1. В репозитории проекта откройте файл, который хотите скачать.

Шаг 2. Когда файл откроется, нажмите кнопку Raw.

Шаг 3. Перед вами — исходный код файла, открытый в браузере. Чтобы его скачать, нажмите правой кнопкой мыши, а потом выберите «Сохранить как…».

Шаг 4. В открывшемся окне можно задать файлу имя и формат. Если планируете работать с кодом в текстовом редакторе, можно оставить .txt.

Способ третий

Использовать расширение

В интернет-магазинах браузеров полно расширений, которые облегчают загрузку с GitHub. Например, GitZip for GitHub помогает скачивать не только файлы, но и целые папки. Рассказываем, как им пользоваться:

Шаг 1. Скачайте и установите утилиту в магазине расширений вашего браузера — есть версии для Chrome, Microsoft Edge и Mozilla.

На заметку: если расширение доступно для Chrome, то запустить его можно в любом браузере, работающем на хромовском движке Blink, — например, в Opera, Vivaldi или «Яндекс.Браузере».

Шаг 2. В репозитории проекта напротив каждого файла появятся чекбоксы — отметьте галочками те, которые хотите скачать.

Шаг 3. Нажмите на кнопку загрузки в правом нижнем углу.

Готово! Можно наслаждаться новыми возможностями до боли знакомого сервиса.

Бонус: как скачивать файлы из GitHub на Android-устройствах

По умолчанию в мобильной версии GitHub нет функции скачивания файлов. Но её можно активировать, если открыть в мобильном браузере версию сайта для ПК. После этого можно будет скачать отдельный файл либо весь проект в виде ZIP-архива.

Если нужен проект целиком:

Шаг 1. Откройте веб-страницу нужного репозитория через Google Chrome.

Шаг 2. В контекстном меню браузера нажмите на кнопку «Версия для ПК».

Шаг 3. После этого страница перезагрузится и откроется обычная десктопная версия сайта. Нажмите зелёную кнопку Code, а потом — Download ZIP.

Если нужен отдельный файл:

Шаг 1. Откройте на GitHub страницу файла и активируйте версию для ПК.

Шаг 2. Когда откроется десктопная версия страницы, нажмите кнопку Raw в правом верхнем углу.

Шаг 3. Снова вызовите контекстное меню браузера и нажмите на значок загрузки в самом верху — после этого на смартфон скачается нужный файл в формате .txt.

К сожалению, на iOS десктопная версия GitHub не открывается ни в одном браузере, поэтому функции Raw и Download ZIP недоступны. Если у вас есть рабочий способ — напишите нам в редакцию, добавим его в статью.

Что дальше

В этой статье мы обсудили нюансы работы только с веб-версией GitHub. Если хотите полностью перенести проект на свой компьютер и работать с ним локально, почитайте нашу статью про GitHub Desktop. Вы узнаете, как создать репозиторий, синхронизировать его с ПК и обновлять файлы удалённо.

Ещё можно почитать материал про систему контроля версий Git. Объясняем на понятных схемах, как работает технология, которая лежит в основе GitHub и других похожих сервисов. Вы поймёте, как там всё устроено, и сможете блеснуть знаниями на собеседовании.

Download a Single File from GitHub: A Guide

When you clone or pull a Git repository , the entire contents of that repository are downloaded by default. Git does not allow you to download part of a repository. Using GitHub, you can download one file from a Git repository.

In this guide, we talk about how to download a single file from GitHub. We walk through two examples to help you learn how to download files from the web browser and the command line.

Download a Single File from GitHub

GitHub lets you download one file from a repository. This is a useful feature because it means you do not have to clone or retrieve an entire repository to download a particular file.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

Select your interest
First name

Last name

Email

Phone number

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

You cannot retrieve a single file using the git command line , even if your repository is hosted on GitHub. You need to use the GitHub web interface, or a direct URL to a file.

To download an individual file from a repository, first navigate to the file you want to download on the GitHub website. Then, click the “Raw” download button that appears on the top right corner of the file explorer window on your page:

In this example, we are viewing the README.md file in a repository called ck-git. When we click “Raw”, we are directed to a plain-text version of our file.

This takes us to the following URL:

Now that we are viewing a plain-text version of our file, we can save it like we would with any web resource. Press Ctrl-S or Cmd-S for Windows and Mac, respectively, and choose where you want to save the file that you are viewing.

Download a Single File Using a URL

We do not need the web interface to view the raw version of a file. We can manually write the URL of the file we want to retrieve.

Let’s take another look at the URL that the web interface pointed us to earlier:

This URL follows a standard format:

We can use this format to retrieve any file from our Git archive, such as a HTML file or a markdown file. We could download a file called app.py in a folder called “main” using this URL:

This method works on both plain text and binary files. If you need to download an image, for example, you’ll be able to do so using this approach.

This approach only works for files that are public. If you want to retrieve a file from a private repository, you’ll need to download it directly from the GitHub web interface. This is because the web interface provides an access token that you need to view a private file.

Venus, a software engineer at Rockbot

«Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!»

Venus, Software Engineer at Rockbot

Find Your Bootcamp Match

Download a Single File Using Wget

We can download a single file from the command line using the wget command. This is because we can write the URL for the file we want to retrieve.

Like the last approach, you can only download a single file using wget if that file is public.

All we have to do to download a single file using wget is write a wget command:

This command retrieves the main/app.py file from our project. The -L flag instructs wget to retrieve only the file that we have specified. We could alternatively use cURL to retrieve the file we want to download.

Conclusion

You can download an individual file from a GitHub repository from the web interface, by using a URL, or from the command line.

You can only retrieve public files by URL or from the command line. This is because private files are protected by an access token that you can only retrieve by viewing a file from the web interface.

Now you have the knowledge you need to download a single file from GitHub like a pro!

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *