Important: if your language has a good dependency management system, then the solution given here is better not to use. Because if it is, it is much easier to make a separate library from the base and install it as a dependency . In Node.js, the NPM package, in Ruby — gem, in PHP — Composer, in Rust — crate, and so on.
Otherwise, there will be redundancy and troubles may be added with updates that can be avoided by initially not using the version control system for other purposes.
git can do that.
In general, I have the impression that git can do anything. True, the mechanism of work is not too simple, you need to understand how it will work.
Since git by its nature distributed, I will emulate your workflow in one local repository on several unrelated branches : a , b and master . Changes in these branches can easily appear from other repositories (different branches can monitor different servers!), But when using this technique you should locally have a repository that has all three.
Let's go point by point:
Suppose that you did git init , and C (the project itself) is in the master branch (which is completely optional).
create a repository with different script files (for example, A)
Make an "unrelated branch":
git checkout --orphan a
We clean the folder and index to start with a clean slate:
git reset && git clean -f
Making a commit with garbage:
echo 'скрипт' | tee script_a_1 script_a_2 git add . git commit # Тут вас попросят ввести сообщение для коммита
the repository, where there will be a standard set of files to start programming the site (for example, B)
Same.
git checkout --orphan b git reset && git clean -f echo 'скрипт' | tee script_b_1 script_b_2 git add . git commit # Сообщение для коммита
When I create a new project, a new repository is created (for example, C).
We assume that this is the master branch. And at the moment it should be empty, for git it means that it does not exist, so you have to do it again:
git checkout --orphan master git reset && git clean -f
Now I need to transfer the standard set from C to C in
Murge:
git merge b
When this happens, fast-forward to b , master will match branch b . This is normal. Indeed, at this stage, the state of the project file system is the same, right?
Then I need to transfer 2 scripts to A from C.
Murge with a , but this time with “brakes”, so that git would stop right before the commit:
git merge --no-commit --no-ff a
What for? Then, that you do not need all the files. At this stage, you can remove unnecessary files from the index from the index with the help of reset , clean up the remaining and commit the result:
git reset script_a_2 git clean -f git commit
Now let's "work a little" for the form:
echo work > work git add work git commit
There is an error in standard files (which are stored in B). I am correcting her and I want to pour both on ...
Since you have (semantically) master based on b , and not vice versa, you need to fix the error in b in order for the changes to "spread" (not automatically!) For those who use it. Go to branch b and repair:
git checkout b # clean уже не нужен, т. к. ветка не пустая echo script > script_b_1 # Ну, допустим, что кириллица не переварилась. Мало ли. git add script_b_1 git commit
At this stage, if the repositories with b and master still different, there should be git push branches b into the corresponding repository, and in the project repository you need to do git pull --ff-only ( --ff-only allows only winding the branch - to Your changes are not "bogged down" in b ) in the branch that is following the repository. This is a separate topic, if you're interested, I'll tell you about it.
... so in C.
Go to the branch with the project:
git checkout master
And we make merge branches b to the project.
git merge b
Is done. Yes, just like that!
After doing the above described manipulations, I received the following scheme from commits ( git log --graph ) in master :
* commit 2e9219cb2922f70382a8f069fdc917bdbfccd4b8 |\ Merge: 2cc463a 1fc0b61 | | Author: Имя <адрес> | | Date: Sun Dec 27 14:46:12 2015 +0300 | | | | мердж фикса | | | * commit 1fc0b61c1017acf4b4ef1941e1cdcb01a7e86be4 | | Author: Имя <адрес> | | Date: Sun Dec 27 14:41:23 2015 +0300 | | | | фикс основы | | * | commit 2cc463ae97500bff4a304990aa4e42159da96fe9 | | Author: Имя <адрес> | | Date: Sun Dec 27 14:38:37 2015 +0300 | | | | работа | | * | commit cfa122c954f77b3282f51511f94bc6d97c95d569 |\ \ Merge: 7da066c f9304d8 | |/ Author: Имя <адрес> |/| Date: Sun Dec 27 14:31:20 2015 +0300 | | | | мердж с удалением лишних | | | * commit f9304d82d89600add270544bec32cd6661a8c150 | Author: Имя <адрес> | Date: Sun Dec 27 13:46:39 2015 +0300 | | скриптики | * commit 7da066c234216057ff19775a355342ed501fe9a4 Author: Имя <адрес> Date: Sun Dec 27 13:54:01 2015 +0300 основа
And for clarity, I redraw:

git clone <repo-b> project-c? - Vitali Falileev