【问题标题】:How to merge a remote repo in a subdirectory of my project?如何在我的项目的子目录中合并远程仓库?
【发布时间】:2015-09-29 06:59:30
【问题描述】:

我想在我的项目的子目录中合并一个远程仓库。几天前,我手动将此远程项目复制为我的项目中的子目录,并对其进行了修改。现在有一个新版本,我想在不丢失修改的情况下合并子目录中的新更改。

结构:

myProject
    /mySubproject1
    /mySubproject2  <-- This one is the modified remote repo (from Github)

我已经尝试过以下链接,但没有成功:

这就是我所做的:

cd myProject    
git remote add -mySubproject2_github https://github.com/something.git
git merge -s ours --no-commit mySubproject2_github/master
git read-tree --prefix=mySubproject2 -u mySubproject2_github/master

但我得到以下内容

错误:条目 'mySubproject2/.something.yml' 与 'mySubproject2/.something.yml'。无法绑定。

这可能是我想要的吗?知道如何解决吗?

【问题讨论】:

  • 如果你想在你的项目中包含这个项目并且你想让它保持最新,你可能需要阅读“git submodules”。
  • @larsks 我可以修改项目吗?当我更新项目时,我可以维护修改吗?
  • @iker 您可以维护一个从上游拉取并维护您的更改的分支。因此,理想情况下,您需要一个单独的存储库。
  • 子模块只是一个 git 存储库......所以,当然。

标签: git github git-merge git-pull


【解决方案1】:

我没有使用有时有点混乱的子模块,而是使用了子树。子树将是我要添加到“父”项目中的项目:

这里是一个例子,我们想在我们的项目中添加来自 Github 的项目 nodejs-y-express。

将子树添加到我们的项目中

$ git subtree add --prefix node_express_subtree https://github.com/codeheroco/nodejs-y-express-rutas master 
git fetch https://github.com/codeheroco/nodejs-y-express-rutas master

从 github 更新项目

git subtree pull --prefix node_express_subtree https://github.com/codeheroco/nodejs-y-express-rutas master

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-19
    • 2012-11-20
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多