Шпаргалка по Git
Навигация
Клонирование
Ошибка при клонировании большого репозитория
Если репозиторий большой, могут возникнуть ошибки:
error: pack-objects died of signal 9383/2871)
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
Для исправления можно попробовать установить параметр --depth=1
. Пример:
git clone --depth=1 ssh://XXXXXXX/assets.zlonov.ru
Пояснение для этой опции:
The
--depth
option works by instructing Git to fetch only the lastn
commits from the remote history wheren
is the number you specify. When you use--depth 1
, you’re telling Git to only fetch the latest commit.--depth 1
is the most commonly used depth. It means you are cloning the repository with only the latest commit of the main branch. The repository is significantly lighter as it contains the minimal amount of data needed to start working with the repository.
Подмодули
Справка про подмодули: https://git-scm.com/book/ru/v2/Инструменты-Git-Подмодули
Инициализация подмодулей
Поcле клонирования репозитория, у которого есть подмодули, их надо инициализировать:
git submodule init
Ошибки при работе с подмодулями
Ошибка с веткой
- Текст ошибки:
fatal: Unable to find refs/remotes/origin/HEAD revision in submodule path
- Вариант решения: явно указать нужную ветку в файле
.gitmodules
. Например, так:
[submodule "catalog"]
path = catalog
url = https://gitflic.ru/project/zlonov/catalog.git
branch = master
[submodule "laws"]
path = laws
url = https://gitflic.ru/project/zlonov/laws.git
branch = master
- Причина: Ошибка «fatal: Unable to find refs/remotes/origin/HEAD revision in submodule path» возникает когда ветка в файле .gitmodules основного проекта отличается от ветки по умолчанию репозитория субмодуля. В примере выше проблема в том, что GitFlic использует отличные от GitHub дефолтные названия веток (
master
вместоmain
). - Ссылки по теме: