Перейти к содержимому

Как скачать папку с github

  • автор:

Скачать с гитхаба *одну* директорию, без истории, в данный момент её истории

Нужно скачать с гитхаба копию (=снэпшот=без истории) некоторой директории (именно некоторой — не хочу скачивать другие, там могут быть большие объёмы картинок-звуков и пр.) в произвольный момент времени, например, директорию include после этого коммита. Изначально никаких данных репы локально нет.

(про svn export знаю, пользуюсь, но он скачивает лишь то что было помечено тагами — брэнчи, а у меня есть лишь некий id коммита, или дерева.).

Какими командами git это можно сделать?

Вообще да, искал. Вот например простыня советов. Но что-то не то совсем советуют, или я не понимаю.

the1 ★★
26.11.18 15:20:23 MSK

Скачать с гитхаба *одну* директорию, без истории, в данный момент её истории

скачать зипник распаковать удалить все каталоги кроме понравившегося.

mos ★★☆☆☆
( 26.11.18 15:29:30 MSK )

Наверное, можно сделать clone с —no-checkout на нужном коммите с последующим «sparse checkout» (StackOverflow, man).

xaizek ★★★★★
( 26.11.18 15:33:28 MSK )

Нельзя, насколько я знаю. Можно скачать одну ветку с одним коммитом:

git clone git_rebo -b branch_or_tag --depth=1 

Можно скачать архив проекта с определённого коммита:

https://github.com/[NICK]/[PROJECT]/archive/[GIT_COMMIT].tar.gz (или zip).

Но чтобы одну только директорию, такого вроде как нет.

EXL ★★★★★
( 26.11.18 15:35:26 MSK )
Ответ на: комментарий от xaizek 26.11.18 15:33:28 MSK

БД/pack-file ведь всё-равно скачается со всеми этими большими объёмами картинок-звуков о которых говорит ТС? Или нет?

EXL ★★★★★
( 26.11.18 15:37:39 MSK )

grem ★★★★★
( 26.11.18 15:42:08 MSK )
Ответ на: комментарий от EXL 26.11.18 15:37:39 MSK

Если в pack-файле будут объекты внутри и вне нужного поддерева, то скорее всего скачается. Но он же может быть не один, так что итоговый объём может оказаться меньше скачивания репозитория полностью.

xaizek ★★★★★
( 26.11.18 15:56:23 MSK )
Ответ на: комментарий от grem 26.11.18 15:42:08 MSK

$ git init Initialized empty Git repository in /mnt/win1/git-play/.git/ $ git remote add origin -f https://github.com/openglredbook/examples Updating origin remote: Enumerating objects: 636, done. ^Cceiving objects: 15% (99/636), 44.54 MiB | 4.11 MiB/s 

Скачивает — минус номер раз. И как задать ревизию — я непонял — минус номер два. (а когда ветвь=мастер, svn export вполне решение).

the1 ★★
( 26.11.18 16:01:03 MSK ) автор топика

Выбирай каждый файл отдельно и скачивай raw вариант через веб-интерфейс.

i-rinat ★★★★★
( 26.11.18 16:35:15 MSK )
Ответ на: комментарий от i-rinat 26.11.18 16:35:15 MSK

Спасибо всем! Иногда я думаю, это я туплю, или мир настолько несовершенен. Спасибо.

the1 ★★
( 26.11.18 16:39:35 MSK ) автор топика
Ответ на: комментарий от the1 26.11.18 16:01:03 MSK

Это чё, ещё и svn ставить?

Какую ещё ревизию? Как в гит переключить ревизию — отдельный вопрос: git checkout commit_hash

Конечно скачивает, а ты что в начале хотел?

grem ★★★★★
( 26.11.18 17:57:22 MSK )
Последнее исправление: grem 26.11.18 18:02:47 MSK (всего исправлений: 2)

За то время пока ты ждал ответа на этот вопрос или читал SO или читал бы man если бы git это умел, эту жалкую сотню метров репозитория можно было скачать на любом соединении быстрее модема. И что ты сэкономил в итоге?

А так — на, не благодари. Список файлов ты мог бы узнать через API.

#!/bin/sh -eu COMMIT=f3f94c7ed38034a6cf751dd713aa55f8580dc9bf files=" GL/glcorearb.h GL/glext.h GL3/gl3.h GL3/gl3w.h Shares/Cube.h Shares/Teapot.h CheckError.h LoadShaders.h mat.h vapp.h vbm.h vec.h vermilion.h vgl.h vmath.h vutils.h " for f in $files; do echo "Fetching $f" mkdir -p $(dirname $f) curl --silent https://raw.githubusercontent.com/openglredbook/examples/$commit/$f > $f done 

slovazap ★★★★★
( 26.11.18 19:13:14 MSK )
Последнее исправление: slovazap 26.11.18 19:13:50 MSK (всего исправлений: 1)

Скачивание архивов исходного кода

Вы можете скачать моментальный снимок кода в репозитории.

Overview of source code archives

You can download a snapshot of any branch, tag, or specific commit from GitHub.com. These snapshots are generated by the git archive command in one of two formats: tarball or zipball. Snapshots don’t contain the entire repository history. If you want the entire history, you can clone the repository. For more information, see «Cloning a repository.»

Downloading source code archives

You can download the source code archives in three ways.

Downloading source code archives from the repository view

  1. On GitHub.com, navigate to the main page of the repository.
  2. Above the list of files, click

Screenshot of the list of files on the landing page of a repository. The

Code.

Downloading source code archives from a release

Screenshot of the main page of a repository. A link, labeled

  1. On GitHub.com, navigate to the main page of the repository.
  2. To the right of the list of files, click Releases.

Source code (zip) or

Downloading source code archives from a tag

Screenshot of the main page of a repository. A link, labeled

  1. On GitHub.com, navigate to the main page of the repository.
  2. To the right of the list of files, click Releases.

zip or

Screenshot of the

tar.gz.

Source code archive URLs

Source code archives are available at specific URLs for each repository. For example, consider the repository github/codeql . There are different URLs for downloading a branch, a tag, or a specific commit ID.

Type of archive Example URL
Branch main https://github.com/github/codeql/archive/refs/heads/main.tar.gz
Tag codeql-cli/v2.12.0 https://github.com/github/codeql/archive/refs/tags/codeql-cli/v2.12.0.zip
Commit aef66c4 https://github.com/github/codeql/archive/aef66c462abe817e33aad91d97aa782a1e2ad2c7.zip

Note: You can use either .zip or .tar.gz in the URLs above to request a zipball or tarball respectively.

Stability of source code archives

Source code archives are generated on request, cached for a while, and then deleted. If the same archive is requested again in the future, it’ll be regenerated. It’s important to understand what guarantees GitHub makes about source code archives.

  • An archive of a commit ID will always have the same file contents whenever it’s requested, assuming the commit ID is still in the repository and the repository’s name has not changed.
  • Because branches and tags can move to different commit IDs, future downloads of an archive may have different contents than previously downloaded archives of the same branch or tag. Assuming the branch or tag still points at the same commit ID, it will have the same file contents.
  • The exact compression settings used to generate a zipball or tarball may change over time. The extracted contents won’t change if the branch or tag doesn’t change, but the outer compressed archive may have a different byte layout. GitHub will give at least six months’ notice before changing compression settings.
  • The name of the repository is part of the directory structure inside the archive. Therefore, if the repository name changes, the root directory name will change as well.

If you rely on stability of source code archives for reproducibility (ensuring you always get identical files inside the archive), we recommend using the archives REST API with a commit ID for :ref . Using the commit ID ensures you’ll always get the same file contents inside the archive and you’ll be immune to repositories rewriting tags or moving branch heads.

If you rely on stability of archives for security (for example: to ensure you don’t attempt to unzip a maliciously-crafted file), we recommend using releases instead of using source downloads. For more information, see «About releases.»

You can use something like this third-party GitHub action to create and push these files as part of your release process. The Release Assets REST API can later be used to retrieve them.

Как клонировать с github без верхней папки/корневой (название репозитория)?

Я закинул шаблон на гитхаб и хочу в любой момент скачать его и начать работу. Я создаю на компе папку с названием сайта(1) захожу внутрь и там через терминал клонирую себе репозиторий, но клонируется и корневая папка, есть ли возможность клонировать только внутренние папки и файлы, без папки с названием репозитория?

5bfaf2a972104892411579.png

(2)

  • Вопрос задан более трёх лет назад
  • 2010 просмотров

Как скачать папку с github

Поиск

Скачать Repository с GitHub.com на свой компьютер с помощью Console
Посмотрели 10965 раз(а) Комментариев 2
Последний комментарий : (31 марта 2023 11:52) Need install git console читать. написать комментарий.
Скачать Repository с GitHub.com на свой компьютер с помощью Console
последнее обновление: 23 октября 2018

Допустим мы хотим скачать Repository с https://github.com/mrdoob/three.js

Шаг 1. (создадим на диске свою папку, чтобы туда скачать Repositry)
Создадим на диске D: папку My
Станем внутри папки D:/My

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

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