使用 git-lfs 如何在保留旧分支和存储库的同时使用新存储库设置新分支?

Using git-lfs how do I setup a new branch with a new repository while keeping the old branch and repository?

所以在 git 上有很多关于设置新存储库和添加 b运行ches 等的问题,但在我的例子中 git 的额外元素-lfs 造成了相当多的麻烦。在这一点上,我实际上已经有了答案(一些正在以期望的方式工作的东西),但它是在许多文章和研究之后得出的,为了避免其他人的麻烦,我将它们放在一起。 (作为旁注,如果有人有更好的答案,请插话,我很乐意接受你的回复。

这是我的场景:

Repo - A(包含所有提交和 b运行ches)- 一些开发人员在这里工作

| B运行ch A1--- >> 更多 b运行与其他开发人员一起工作

Repo - B(没有提交或 b运行ches)- 一些开发人员将在这里工作

我需要能够流畅地将代码从一个代码移动到另一个代码,并且开始时 Repo A 只有一个遥控器。哦,是的,涉及 gitlfs - 所以上面提到的大多数演练都没有说明接下来需要发生什么。

当我开始这次冒险时,我的初始设置是克隆 Repo B,然后将 Repo A 带入 B。那是一场灾难,最终的解决方案只是擦除 repo 并重新开始。在做了更多研究之后,我发现更好的解决方案是从 Repo A 进行设置并添加 b运行ch,然后更改远程和上游。这是我 运行 遇到的其中一个错误:

当我开始发出这些命令时,当前在 Repo A 的主 b运行ch 中:

git remote -v

(这显示了您当前的遥控器) 原点 https://something.repoA.git(获取) 原点 https://something.repoA.git(推)

我遇到的错误是这个:

打开C:\somefile: 系统找不到指定的文件 错误:无法将某些引用推送到“https://something.repoB.git

如上所述,我能够将其解决到所需的状态,但是如果这不遵循 git 方法 - 或者会中断并导致合并冲突或历史问题,请分享。

当我开始发出这些命令时,当前在 Repo A 的主分支中:

git checkout -b repoB-branch(这会根据当前签出的分支创建一个分支) 切换到新分支 'repoB-branch'

git remote add repoB-branch git@github.com:username/repoB.git

git fetch repoB-branch master

严重:找不到远程 ref master

git remote -v

来源https://something.repoA.git(获取)

来源https://something.repoA.git(推送)

repoB 分支 https://something.repoB.git(获取)

repoB 分支 https://something.repoB.git(推送)

git push -u repoB-branch master

打开C:\somefile: 系统找不到指定的文件 错误:无法将某些引用推送到“https://something.repoB.git

git lfs install

更新了 git 个挂钩 Git LFS 已初始化。

git lfs track

git add .gitattributes

git push -u repoB-branch master

打开C:\somefile: 系统找不到指定的文件 错误:无法将某些引用推送到“https://something.repoB.git

git lfs fetch --all
git push -u repoB-branch master