简体   繁体   中英

need to connect a new repository to a directory in an existing one

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM