I have the following problem I'm unable to resolve :
I have two version controlled directories on my local machine. One is dirA
which holds a lot of my stuff and is a private repo I don't want to share. The other is dirB
, a small public repo with files I do want to share, it's mainly for others to clone and pull, the changes all come from me.
The thing is that dirB
holds files which are all coming from dirA
, it's basically a subset of dirA
though it has another structure.
Anytime I make changes to the files in dirA
that are also in dirB
, I'd like to update dirB
and then push the updated files to the public repo.
I tried using rsync
and unison
but I have to do it by hand anytime I update the specific files I mentioned, it's not very efficient. I gathered git submodules or hooks could help me but I don't understand what tool I should use.
In substance, I have :
dirA/ (larger private repo with my stuff)
|
|--- file1
|
|--- file2
.
.
.--- fileN
and
dirB/ (public repo that I want to update only when the relevant files from dirA are updated)
|
|--- SubjectA/
| |
| |--- file3
|
|--- SubjectB/
|
|--- file11
.
.
Ideally, I'd like that when I update dirA
locally and push to remote, dirB
is updated locally as well and then it'd be pushed to remote as well.
How can I achieve this ?
Thanks.
Since your requirement is to keep files in sync and also be able to push real files(not plain links) you could simply create hardlinks for files of interest.
You could create a hard link as follows :
ln <src-file-path> <path-to-the-link>
This should create a hardlink for your file, any changes in original file reflects in the newly created file and pushing to the repository results in a genuine file, not a link.
NOTE: Make sure that you don't provide the -s
switch as it will create a soft-link instead.