I ran into this problem recently, when attempting to migrate a repository (repo) from my personal gitea instance to github. It started innocently enough. I had a git repository and wanted to test parallel test runs with cypress. The CI provider I was using (drone), did not support this feature and, after speaking with the cypress folks, they suggested trying with github actions. Sure. Why not. Should be easy. Little did I know this would lead me down a git-lfs sized rabbit hole.
So, first things first, I performed the git repo migration incorrectly. I forgot all about the git-lfs files that were in this repo, so my migration looked something like this.
- Modify existing repo’s
.git/config
file to replace origin and point to github. - Push to github
- Done
The problem with doings things this way is that there are things that need to happen to push the lfs stored objects to their new location that did not happen.
When cloning, git is not set up—by default—to automatically download files from the lfs location. Everything seemed fine when I cloned the repo from the new location, like so:
Cloning into 'inspiringhopechurch.com.g'...
remote: Enumerating objects: 1748, done.
remote: Counting objects: 100% (1748/1748), done.
remote: Compressing objects: 100% (519/519), done.
remote: Total 1748 (delta 1210), reused 1727 (delta 1197), pack-reused 0
Receiving objects: 100% (1748/1748), 5.48 MiB | 5.33 MiB/s, done.
Resolving deltas: 100% (1210/1210), done.
But it should have looked more like so:
Cloning into 'inspiringhopechurch.com.g'...
remote: Enumerating objects: 1748, done.
remote: Counting objects: 100% (1748/1748), done.
remote: Compressing objects: 100% (519/519), done.
remote: Total 1748 (delta 1210), reused 1727 (delta 1197), pack-reused 0
Receiving objects: 100% (1748/1748), 5.48 MiB | 4.99 MiB/s, done.
Resolving deltas: 100% (1210/1210), done.
Filtering content: 100% (12/12), 47.80 MiB | 7.65 MiB/s, done.
If we have already cloned, we can use the git lfs
command within the repo to pull the lfs files with git lfs pull
. Even with these options there are still problems. We still haven’t pushed to the new repo’s lfs storage yet. So a git lfs pull
will give the following error:
[7bc8118e51aac96a07f0123b5dfa8325a9d7404fa998d63776f08a9cc8237c0c]
Object does not exist on the server: [404] Object does not exist on the server
error: failed to fetch some objects from 'https://github.com/user/repo.git/info/lfs
To make git pull from lfs storage while cloning we can add some options to ~/.gitconfig
, e.g.:
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
But if we do that then (since the repo still doesn’t have the lfs files) you’ll get a smudge error during cloning:
Cloning into 'repo'...
remote: Enumerating objects: 1736, done.
remote: Counting objects: 100% (1736/1736), done.
remote: Compressing objects: 100% (511/511), done.
remote: Total 1736 (delta 1202), reused 1719 (delta 1193), pack-reused 0
Receiving objects: 100% (1736/1736), 5.48 MiB | 6.79 MiB/s, done.
Resolving deltas: 100% (1202/1202), done.
Downloading static/assets/webfont.woff (14 KB)
Error downloading object: static/assets/webfont.woff (7d3a21b): Smudge error: Error downloading static/assets/webfont.woff (7d3a21b4869056b06276f51018070848c876d86570c56f9fdf726d8fed53ae9d): [7d3a21b4869056b06276f51018070848c876d86570c56f9fdf726d8fed53ae9d] Object does not exist on the server: [404] Object does not exist on the server
You could try to restore from git but then you’d get the error:
git restore --source=HEAD :/
Downloading static/assets/webfont.woff (14 KB)
Error downloading object: static/assets/webfont.woff (7d3a21b): Smudge error: Error downloading static/assets/webfont.woff (7d3a21b4869056b06276f51018070848c876d86570c56f9fdf726d8fed53ae9d): [7d3a21b4869056b06276f51018070848c876d86570c56f9fdf726d8fed53ae9d] Object does not exist on the server: [404] Object does not exist on the server
Errors logged to ~/Source/repo/.git/lfs/logs/20210223T220123.881257.log
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: static/assets/webfont.woff: smudge filter lfs failed
OK, I’ll stop talking about all the possible errors. Hopefully by now you’ve picked up on what the solution is. Push the files using git lfs
to the new repo. How does one do that?
git lfs push --all git@github.com:user/repo.git
This was done in the original repo where I modified the .git/config
file to point to the new origin.
There you have it, all that exposition for a one line solution. Hopefully, the long explanations help you (and future me) understand the problem and make it clear why the solution is as simple as it is. It took me a while to get to that point, but now I have a better understanding of what git lfs does, and more importantly, what I should (not) do when migrating future git repos.
So here’s the right way to migrate git repos with lfs files in 2021.
git push --mirror git@github.com:user/repo.git
git lfs push --all git@github.com:user/repo.git
I’m not sure if this is the right forum to discuss git-lfs but as we have a tag for it I’ll post my question. I have read the «Troubleshoot Git LFS in Bitbucket» page.
I’m getting the following error when runing:
ssh-agent bash -c 'ssh-add /home/dan/.ssh/keyname; git clone git@bitbucket.org:[repo name removed].git'
$ git-lfs smudge — [Filename removed].zip Error downloading object:
[Filename removed].zip ([code removed]): Smudge error: Error downloading
[Filename removed].zip ([code removed]): [[code removed] Object does
not exist on the server: [404] Object does not exist on the server[404] Object does not exist on the server
github.com/git-lfs/git-lfs/errors.newWrappedError
/tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170:
[[code removed]] Object does not exist on the server
github.com/git-lfs/git-lfs/errors.newWrappedError
/tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170:
Error downloading [Filename removed].zip ([code removed])
github.com/git-lfs/git-lfs/errors.newWrappedError
/tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170:
Smudge error
Has anyone got any advice?
Vadim Kotov
7,9548 gold badges48 silver badges62 bronze badges
asked Oct 2, 2017 at 7:26
I eventually found an answer by strich: on https://github.com/git-lfs/git-lfs/issues/911
I’ve had similar issues in the past and I think there may be a
potential bug in cloning with git lfs (Still to be determined). You
can try this method of fetching the repo, which is in fact faster too:
// Skip smudge - We'll download binary files later in a faster batch
git lfs install --skip-smudge
// Do git clone here
git clone ...
// Fetch all the binary files in the new clone
git lfs pull
// Reinstate smudge
git lfs install --force
This only needs to be done once to initialize the clone for the first
time.Please do test it and let me know if it fixes it.
ian
11.8k9 gold badges48 silver badges106 bronze badges
answered Oct 2, 2017 at 9:54
Dan-DevDan-Dev
8,6623 gold badges41 silver badges53 bronze badges
3
This corruption can happen due to another developer’s misconfigured git-lfs that pushed to the repository, or sometimes due to some unusual failure during a push. Try re-sending the missing object (using its object ID) from a working tree:
git lfs push --object-id <remote> <oid>
The OID should be in the Smudge error message.
answered Jan 30, 2019 at 4:45
DangerDanger
2112 silver badges3 bronze badges
6
Open
Issue created Oct 22, 2019 by
smudge filter lfs failed
Summary
gitlab-runner arch=amd64 os=windows pid=38676 revision=1564076b version=12.4.0 does have the problem that it is not able to pull a project with LFS content and it is also not able to skip it.
Please help me somehow. I will go insane with that. I searched the whole web for solutions. I already know that the GIT_LFS_SKIP_SMUDGE consideration was fixed in earlier versions but somehow it does not work. It does not matter if I use GIT_LFS_SKIP_SMUDGE: «1» or GIT_LFS_SKIP_SMUDGE: 1 . It will have the same behaviour.
I also set following in the globals of the running machine sadly without effect
git config filter.lfs.process = «git-lfs filter-process —skip
git config filter.lfs.smudge = «git-lfs smudge —skip %f
I upgraded today to 12.4 the problem also exists in 12.3
Steps to reproduce
Load up an LFS file to a project and try a pipeline on it.
.gitlab-ci.yml
variables:
GIT_LFS_SKIP_SMUDGE: "1"
GIT_SUBMODULE_STRATEGY: recursive
stages:
- Pull
- Test
- Build
- Deploy
GIT-Pull:
before_script:
- Write-Host 'Start Pulling LFS files...'
script:
- git-lfs install
- git-lfs pull
stage: Pull
tags:
- Unity
Unit-Test:
before_script:
- Write-Host 'Start Unit-Tests...'
- $PROJECTLOCATION = Get-Location
- $PROJECTVERISONFILEPATH = Get-ChildItem -Path (Get-Location) -Filter ProjectVersion.txt -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
- $PROJECTVERISONFILECONTENT = Get-Content -Path $PROJECTVERISONFILEPATH
- $UNITY_PROJECT_VERSION = $PROJECTVERISONFILECONTENT.split(":")[1] -replace " ", ""
- Write-Host $UNITY_PROJECT_VERSION
script:
- Invoke-Expression '&C:"Program Files"UnityHubEditor$UNITY_PROJECT_VERSIONEditorUnity.exe -batchmode -branch $CI_COMMIT_REF_NAME -projectPath $PROJECTLOCATION -runEditorTests -logFile $PROJECTLOCATIONUnityConsoleLog.txt -editorTestsResultFile ./unit-Tests.xml -ErrorAction Stop | Out-Null' -ErrorAction Stop
- Write-Host $LASTEXITCODE
- if($LASTEXITCODE -ne 0) { $Host.SetShouldExit($LASTEXITCODE)}
after_script:
- $FullPathNameUnitTestXML = Get-ChildItem -Path (Get-Location) -Filter unit-Tests.xml -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
- $FullPathNameUnitTestHTMLViewer = Get-ChildItem -Path (Get-Location) -Filter UnityUnitTestViewer.html -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
- Copy-Item $FullPathNameUnitTestHTMLViewer -Destination "./TestResults.html"
- $XMLTestContent = Get-Content -Path $FullPathNameUnitTestXML
- $XMLTestContent = ($XMLTestContent -split "(r*n){2,}") -replace 'r*n', ''
- (Get-Content ./TestResults.html).replace('###UNITY_UNITTEST_XML_TO_REPLACE###', $XMLTestContent) | Set-Content ./TestResults.html
stage: Test
artifacts:
name: "Unit-Test Results"
when: always
paths:
- ./TestResults.html
- ./unityConsoleLog.txt
tags:
- Unity
Unity-Build:
before_script:
- Write-Host 'Building...'
- $PROJECTLOCATION = Get-Location
- $PROJECTVERISONFILEPATH = Get-ChildItem -Path (Get-Location) -Filter ProjectVersion.txt -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
- $PROJECTVERISONFILECONTENT = Get-Content -Path $PROJECTVERISONFILEPATH
- $UNITY_PROJECT_VERSION = $PROJECTVERISONFILECONTENT.split(":")[1] -replace " ", ""
- Write-Host $UNITY_PROJECT_VERSION
script:
- Invoke-Expression '&C:"Program Files"UnityHubEditor$UNITY_PROJECT_VERSIONEditorUnity.exe -batchmode -branch $CI_COMMIT_REF_NAME -projectPath $PROJECTLOCATION -nographics -logFile $PROJECTLOCATIONUnityConsoleLog.txt -executeMethod CICD_UnityGitlab.CIBuilder.Build -ErrorAction Stop | Out-Null' -ErrorAction Stop
- Write-Host $LASTEXITCODE
- if($LASTEXITCODE -ne 0) { $Host.SetShouldExit($LASTEXITCODE)}
artifacts:
name: "Build"
paths:
- ./Releases
- ./unityConsoleLog.txt
stage: Build
tags:
- Unity
Deployment:
before_script:
- Write-Host 'Deploying...'
- $PROJECTLOCATION = Get-Location
- $PROJECTVERISONFILEPATH = Get-ChildItem -Path (Get-Location) -Filter ProjectVersion.txt -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
- $PROJECTVERISONFILECONTENT = Get-Content -Path $PROJECTVERISONFILEPATH
- $UNITY_PROJECT_VERSION = $PROJECTVERISONFILECONTENT.split(":")[1] -replace " ", ""
- Write-Host $UNITY_PROJECT_VERSION
script:
- Invoke-Expression '&C:"Program Files"UnityHubEditor$UNITY_PROJECT_VERSIONEditorUnity.exe -batchmode -branch $CI_COMMIT_REF_NAME -projectPath $PROJECTLOCATION -nographics -executeMethod -logFile $PROJECTLOCATIONUnityConsoleLog.txt CICD_UnityGitlab.CDDeployer.Deploy -ErrorAction Stop | Out-Null' -ErrorAction Stop
- Write-Host $LASTEXITCODE
- if($LASTEXITCODE -ne 0) { $Host.SetShouldExit($LASTEXITCODE)}
artifacts:
name: "DeploymentLog"
paths:
- ./unityConsoleLog.txt
stage: Deploy
tags:
- Unity
Actual behavior
Pipeline fails on LFS-Files
Expected behavior
There shouldn’t be any issues with LFS-Files
But there are issues and GIT_LFS_SKIP_SMUDGE: «1» should be considered at least so that lfs handling can be overridden
Relevant logs and/or screenshots
job log
Running with gitlab-runner 12.4.0 (1564076b)
on MWS2016034564(PIXYZ) 4c3837a7
Using Shell executor...
Running on MWS2016034564...
Fetching changes...
Initialized empty Git repository in E:/GitLab-Runner/builds/4c3837a7/0/cgi/Unity/ConfigurationSystem/.git/
Created fresh repository.
From https://mm-gitlab-cgi.meyle-mueller.de/cgi/Unity/ConfigurationSystem
* [new branch] develop -> origin/develop
.
.
.
.
Checking out bbe35f97 as develop...
error: external filter 'git-lfs filter-process' failed
fatal: Assets/AddressableAssetsData/WebGL/addressables_content_state.bin: smudge filter lfs failed
ERROR: Job failed: exit status 1
Environment description
gitlab runner is used with shell execution
No multi-runner
config.toml
is empty
config.toml contents
Used GitLab Runner version
Version: 12.4.0
Git revision: 1564076b
Git branch: 12-4-stable
GO version: go1.10.8
Built: 2019-10-21T14:37:13+0000
OS/Arch: windows/amd64
—>
Root Cause
#4808 (comment 241406769)
Edited Nov 15, 2019 by Steve Azzopardi
#git #atlassian-sourcetree #unreal-engine4 #pull #git-lfs
#git #atlassian-sourcetree #unreal-engineer4 #тянуть #git-lfs
Вопрос:
Я являюсь частью команды разработчиков игр. Мы разрабатываем игру Unreal Engine 4 для ПК. У нас есть частный сервер GitLab, обрабатывающий управление версиями проекта.
Прямо сейчас, когда кто-либо пытается выполнить Git Pull из определенной ветви нашего проекта Git, он получает ошибку Smudge:
Downloading UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_A.uasset (1.3 MB)
Error downloading object: UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_A.uasset (c366451): Smudge error: Error downloading Ue4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_A.uasset (c366451e360519497bf1719bacdc40c938c833adf9b8060d90d0829fec15d6c8): expected OID c366451e360519497bf1719bacdc40c938c833adf9b8060d90d0829fec15d6c8, got e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 after 0 bytes written
error: external filter 'git-lfs filter-process' failed
fatal: UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_A.uasset: smudge filter lfs failed
Мы попросили разработчика, который создал эту ветку, удалить Bucket_A.uasset
и повторно выполнить изменение. Когда кто-либо пытается выполнить Git Pull сейчас, он получает ошибку размытия с другим файлом:
Downloading UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_C.uasset (1.4 MB)
Error downloading object: UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_C.uasset (4023793): Smudge error: Error downloading UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_C.uasset (40237933795d4ca4b4c58e2884e219c3e4cd8168af176f01b33d71e3353376d7): expected OID 40237933795d4ca4b4c58e2884e219c3e4cd8168af176f01b33d71e3353376d7, got e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 after 0 bytes written
error: external filter 'git-lfs filter-process' failed
fatal: UE4Proj/Content/Game/Art/Architecture/MedievalVillage/Textures/Bucket_C.uasset: smudge filter lfs failed
Так что это не какой-то изолированный инцидент: похоже, что для нескольких файлов могут быть ошибки размытия. Действительно усугубляющая часть заключается в том, что ошибка размытия отображается только примерно на 99% от Git Pull, поэтому просмотр и удаление файла с ошибкой размытия (какой бы она ни была) вручную после часа или двух попыток Git Pull, а затем повторной очистки изменений, оказывается огромнымрутинная работа и, безусловно, вызовет проблемы с самим проектом Unreal Engine (поскольку текстуры теперь будут отсутствовать).
Unreal Engine сообщает об отсутствии проблем ни для одного из этих файлов UASSET, что говорит мне, что с содержимым этих файлов все в порядке.
Для Git-извлечения проекта у нас есть член команды, использующий SourceTree и командную строку Windows. Все они получают эту же ошибку.
Что такое ошибка размытия и есть ли какие-либо рекомендации по их устранению, чтобы мы могли успешно выполнить эту ветку Git? Это проблема, которая должна быть решена отдельными съемниками, толкателем и / или хостом сервера Git?
Ответ №1:
Итак, я решил проблему: в итоге мы откатили нашу виртуальную машину GitLab на время, предшествующее Git Push, из-за которого виртуальная машина GitLab заблокировалась (потребовалось несколько попыток, прежде чем в то время была запущена ветка Git). После отката виртуальной машины GitLab я добавил больше оперативной памяти и процессора к виртуальной машине: ветка Git была снова запущена, и на этот раз без блокировки виртуальной машины GitLab. После успешного нажатия ветвь может быть извлечена без ошибок! Таким образом, мы больше не получаем Smudge Error
s при извлечении ветки (или любой другой ветки в проекте Git, если на то пошло, как я объясню далее).
Мы считаем, что с тех пор, как произошло событие блокировки виртуальной машины GitLab во время Git Push, репозиторий Project Git был поврежден. Действительно, любой, кто извлекал из любой из наших ветвей проекта (по какой-то причине за исключением master), получал Smudge Error
s, в том числе из предыдущих ветвей, которые раньше можно было извлекать без ошибок! Я очень благодарен, что на нашем сервере Git выполняются регулярные снимки и резервные копии.
Предупреждение всем, у кого есть Git-сервер: если будет предпринята большая попытка, сначала сделайте снимок и сделайте резервную копию Git-сервера. Поверьте мне, вам ДЕЙСТВИТЕЛЬНО не нужен поврежденный репозиторий Git!
Ответ №2:
Git LFS использует фильтр размытия и очистки, чтобы превратить файлы указателей в репозитории в большие файлы, которые вы вернули. Процесс размытия — это этот процесс.
Сообщение, которое вы видите, связано с тем, что Git LFS пытается загрузить объект с сервера, и его хэш неверен. Git LFS использует SHA-256 для идентификации файлов, и файл, который он получает, является пустым файлом (который e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
является хэшем), а не файлом, который вы предполагали. Это проблема на вашем сервере; это не проблема с Git или Git LFS.
Если вы попытаетесь загрузить объект снова, GitLab, вероятно, подумает, что у него уже есть объект, и не будет запрашивать его загрузку. Вам нужно будет указать GitLab удалить существующий объект, как бы это ни было сделано, а затем снова отправить объект от клиента, у которого он есть.
Если вы видите большое количество файлов с этой проблемой, у вашего экземпляра GitLab может возникнуть серьезная проблема. Усеченные файлы нулевой длины являются распространенной проблемой при сбое компьютера, и вам следует проверить свой экземпляр GitLab на наличие каких-либо проблем. Если вы не уверены, как это сделать, вам следует обратиться в GitLab за поддержкой.
Комментарии:
1. Вы уверены, что это проблема с нашим сервером, а не с Git Push, который был выполнен? Похоже, именно об этом сейчас думает наш Ведущий Программист. Есть ли способ удалить определенные файлы из ветки с помощью Git (GitLab не позволяет удалять файлы LFS в веб-графическом интерфейсе) и повторно загружать их? Или вся ветка нуждается в удалении, а вся ветка нуждается в повторной загрузке? Это большая ветка.
2. Ваш сервер должен проверять размер загружаемого объекта и не принимать объект, если он не соответствует размеру, даже если он не проверяет хэш, поэтому ваш сервер не работает, если он этого не делает. Протокол загрузки Git LFS предназначен для выполнения операции проверки, при которой сервер может проверить загруженный объект. Однако он не предоставляет способа удаления объектов. Я не могу говорить о том, что делает или не делает GitLab; Я не знаком с этим, поэтому вам придется спросить их.
3. Я полагаю, вы правы, что это действительно сервер или, возможно, весь репозиторий проекта: основная ветка в порядке, но когда кто-либо пытается извлечь данные из любой другой ветки, они получают «ошибки размытия». Я понятия не имею, что мне нужно сделать, чтобы исправить ситуацию. Есть ли у вас какие-либо рекомендуемые сообщества Git или Git LFS, к которым я мог бы обратиться? Я очень беспокоюсь, что мне нужно будет обратиться не только к сообществу GitLab.
4. Вы можете задать вопрос на доске обсуждений Git LFS на GitHub . Это не проблема, поэтому открывать ее как проблему было бы неправильно. Я скажу вам, что в проекте Git LFS не так много людей, знакомых с GitLab, поэтому я обязательно сначала спрошу GitLab.