我有一个包含2个lfs跟踪文件的repoA。我像这样将那个仓库带入repoB
cd repoB
git fetch repoA somebranch
git checkout -b temp FETCH_HEAD
git rebase someotherbranch
Run Code Online (Sandbox Code Playgroud)
这将打印几行“正在应用:...”,然后
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes
Please, commit your changes or stash them before you can merge.
Aborting
error: Failed to merge in the changes.
Patch failed at 0340 update server
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Run Code Online (Sandbox Code Playgroud)
我该如何解决?注意:此文件在repoA中不存在。这个问题似乎与git lfs的问题完全相关。
git状态显示了这个
$ git status
rebase in progress; onto 5af1f30
You are currently rebasing branch 'gamepad' on '5af1f30'.
(all conflicts fixed: run "git rebase --continue")
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes
deleted: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.sha256.bytes
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
注意:我尝试仅添加和提交2个文件(伏都教),然后git rebase --continue一直进行到下一次在历史记录中修改文件时,此时出现了类似的错误。我做了同样的事情,终于完成了。但是当我尝试将其重新建立到另一个分支时,我得到了
Downloading Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes (7.48 MB)
Error downloading object: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes (4743b094eeab821140773213ebabdaa81c9ac2eb1be1108e70e8d51ae52873dd)
Errors logged to /Users/gregg/src/hft-unity3d/.git/lfs/objects/logs/20160603T213456.110362284.log
Use `git lfs logs last` to view the log.
error: external filter git-lfs smudge -- %f failed 2
error: external filter git-lfs smudge -- %f failed
fatal: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes: smudge filter lfs failed
Could not apply dc378b5d715103e9af0ee805ff2a3be1159739aa... add lfs support
Run Code Online (Sandbox Code Playgroud)
哪种建议我不知道如何正确使用git lfs。
因此,事实证明您必须在每个存储库中安装git lfs。这是不是在所有不清楚的文档这说
您只需要设置一次Git LFS。
Run Code Online (Sandbox Code Playgroud)git lfs install
事实证明,每个回购一次,实际上不是一次。
然后,仔细阅读问题,它需要知道从何处获取远程存储的文件。它基于被跟踪的任何远程分支来执行此操作,从头开始
git clone git@github.com/me/repoA
cd repoA
git lfs install
git remote add repoB git@github.com/me/repoB
git fetch repoB
git checkout -b temp repoB/somebranch
Run Code Online (Sandbox Code Playgroud)
这开始将repoB / somebranch检出为临时文件,但失败
Downloading Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes (7.48 MB)
Error downloading object: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes (f8c42a7c55f610768ce50ff93d09fc63fa897de867290dafee2e84d64e10de4e)
Errors logged to /Users/gregg/temp/delme-hft-unity3d/.git/lfs/objects/logs/20160603T231351.670335751.log
Use `git lfs logs last` to view the log.
error: external filter git-lfs smudge -- %f failed 2
error: external filter git-lfs smudge -- %f failed
fatal: Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes: smudge filter lfs failed
Run Code Online (Sandbox Code Playgroud)
AFAIK我现在正在跟踪正确的分支。这是文件上传到的同一远程上的同一分支。
从最后一个开始,但origin在克隆repoA之后更改为指向repoB
git clone git@github.com/me/repoA
cd repoA
git lfs install
git remote remove origin
git remote add origin git@github.com/me/repoB
git fetch repoB
git checkout -b temp origin/somebranch
Run Code Online (Sandbox Code Playgroud)
这可以像以前一样失败
但现在
git checkout -b other master
git branch --set-upstream-to origin/somebranch
git rebase master temp
Run Code Online (Sandbox Code Playgroud)
与以前相同的地方失败
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes
Please, commit your changes or stash them before you can merge.
Aborting
error: Failed to merge in the changes.
Patch failed at 0358 update server
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Run Code Online (Sandbox Code Playgroud)
好吧,显然问题是当 git 调用 hooks 时,它不会传递当前的跟踪分支信息,因此 lfs 无法找到文件。它只是默认使用origin的链接
因此,要做到这一点,您需要使用该--skip-smudge选项安装 lfs 。这基本上会告诉lfs不要下载文件。按预期进行合并,然后git lfs pull它有一个远程参数,让您告诉它从哪里获取文件
一旦这一切都完成了,我假设你可以打字git lfs install让它恢复正常。您可能需要执行 agit lfs fetch --all repoB并将git lfs push --all repoA somebranch您从先前存储库的 lfs 存储 (repoB) 下载到新存储库的 lfs 存储 (repoA) 的所有文件
这个github问题的所有步骤
# This disables smudging for the 'git clone'
# and then calls 'git lfs pull' for you
git lfs clone git@github.com:me/repoB.git
cd repoB
git lfs install --skip-smudge --local # affects only this clone
git fetch repoA
git checkout -b temp repoA/somebranch
git rebase master
git lfs fetch --all repoA
git lfs checkout
git push origin temp
git lfs push --all origin temp
git lfs install --force --local
Run Code Online (Sandbox Code Playgroud)
该git lfs pull命令本质上与调用git lfs fetch(下载 LFS 对象)和git lfs checkout(将本地下载的文件复制到您的工作目录)相同。因此,我的示例仅通过git lfs fetch --all命令下载对象。
如果要为单个命令禁用污迹过滤器,还可以使用GIT_LFS_SKIP_SMUDGE:
$ GIT_LFS_SKIP_SMUDGE=1 git pull
$ git lfs pull
Run Code Online (Sandbox Code Playgroud)
repoA修改文件的提交Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes。
同样的文件也位于repoB工作树中。Git 知道您无法替换该文件。要纠正它,您必须按照 git 的建议进行操作。Git 经常告诉你如何纠正错误。
隐藏或提交您的本地更改。在你的情况下,最好存储你的更改,进行变基,弹出存储。这给你以下命令。
cd repoB
git stash
git fetch repoA somebranch
git checkout -b temp FETCH_HEAD
git rebase someotherbranch
git stash pop // You may need to resolve conflict using git mergetool
Run Code Online (Sandbox Code Playgroud)
在开始之前,请务必避免之前的变基尝试。
| 归档时间: |
|
| 查看次数: |
2640 次 |
| 最近记录: |