需要将新的存储库连接到现有的存储库

需要将新的存储库连接到现有的存储库

本文介绍了需要将新的存储库连接到现有的存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,其中包含一个目录:

  repository / libs / somelibrary 

这个目录现在被分成不同的存储库,但是当这个过程正在进行时,我的团队会继续对这个目录。
因此,我创建了一个新的存储库 - somelibrary - 它将包含像这样的原始文件:

   -  somelibrary 
- src
- 原始目录结构
- package.json
- Gruntfile.js

我在寻找一种简单的方法来保持src目录与原始存储库中的提交同步:

  somelibrary / src / ** => repository / libs / somelibrary / ** 

有没有办法做到这一点?

解决方案

这似乎是一个很好的应用案例。首先将原始存储库添加为 somelibrary 的一个远程位置:

  git remote add original repository 

然后取回它:

  git fetch original 

然后开始将原始资料库合并到 somelibrary 中:

  git merge -s our --no-commit original / master 

只导入正确的子树进入等待提交:

  git read-tree --prefix = src / -u original / master:libs / somelibrary 

然后使用 git commit

I have a repository, that contains a directory:

repository/libs/somelibrary

this directory is now to be separated into a different repository but, while this process is going on, my team will keep commiting changes to this directory.
So I created a new repository - somelibrary - which will contain the original files like so:

- somelibrary
   - src
       - the original directory structure
   - package.json
   - Gruntfile.js

What i'm looking is for an easy way to keep that src directory in sync with the commits in the original repository:

somelibrary/src/** => repository/libs/somelibrary/**

Is there a way to do this?

解决方案

This seems to be a good application case for subtree merging. First add the original repository as a remote to somelibrary:

git remote add original repository

Then fetch it:

git fetch original

Then initiate a merge of the original repository into somelibrary:

git merge -s ours --no-commit original/master

Only import the correct subtree into the pending commit:

git read-tree --prefix=src/ -u original/master:libs/somelibrary

Then finalize the commit with git commit

这篇关于需要将新的存储库连接到现有的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 19:53