1

我拥有两个 git 存储库: AB,它们都主要用于自己的 master 分支。

A包含以下文件夹:

  • 文件夹1
  • 文件夹2

B包含此文件夹:

  • 文件夹3

为了部署A包含folder3,我想folder3B推送到A。我希望这种关系只是单向的,这意味着A更新B但没有pullBA

我最终会得到包含这些文件的 A:

  • 文件夹1
  • 文件夹2
  • 文件夹 3(被推)

当然,关于第一次部署,A并不知道folder3的存在。

因此,我在网上找到了命令git subtree似乎可以很好地完成此任务。

因此,我尝试在B存储库的目录上完成此任务的整个过程是:

git remote add A https://githubAdressOfA
git subtree prefix --folder3 --squash A master 

但是,我遇到了这种错误:

Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.

据我说,pull在我上面解释的单向场景的情况下, B repo 不应该需要“子树”的概念。

如何有效处理这种情况?也许我滥用subtree了命令...

4

0 回答 0