Is it possible to clone a git repository, and split the clone repo, keeping track of the changes from original repo?
This might be somewhat unusual, but say I have a git repository A:
A/project1/... A/project2/... A/project3/...
and clone this repository to B:
B/project1/... B/project2/... B/project3/...
What I want to do is to somehow split the project folders and their contents into individual units. It does not really matter if the unit is a branch, a repository or whatever, the important thing here is that I need to be able to efficiently fetch changes from repository A upstream, and track in B’s units.
I want to use Jenkins and only build the projects if they contain changes, and Jenkins supports this for a single repository or branch. However, I can not change the original repository A. Alternative solutions are of course also very welcome.
One Solution collect form web for “Is it possible to clone a git repository, and split the clone repo, keeping track of the changes from original repo?”
Sparse checkouts may be of help here.
- You need to clone the repository A.
- You then have to configure sparse checkout (after cloning):
git config core.sparsecheckout true
echo project1/ > .git/info/sparse-checkout
- Then you need to call
git read-tree -m -u HEAD
However the sparse checkout is not truly independent. Let us say you want only
project1. Changes introduced by
project3 in your case will suggest that your sparse checkout has changed.
- Checkout sub directories in git