I have a quite specific workflow and the reason for that is that I use git subtree to include one project inside another:
- a local git repository styling which is updated by pull from a remote repository (styling-exchange);
- another local repository styling-bare which is used to sync styling and code
- a remote production repository which can be updated from code with git push production master
It should look like this:
code |--/.git |--.gitignore |--/styling | |--file1 | |--file2.v1 |--file3 styling-bare styling |--/.git |--.gitignore |--file1 |--file2.v2
There are two use cases for the workflow:
- cd into styling, pull from styling-exchange, then cd into code, update the styling subtree, do some changes to file1 and file2 and file3, push to production
- cd into code, do some changes to file1 and file2 and file3, push changes to styling-bare (subtree push), cd into styling, pull from styling-bare, push changes to styling-exchange
I would like to have two completely different and separate versions of file2 in the local repositories styling/styling-bare VS the code/production repositories. I need to get all updates from the styling subtree into code/styling, but I need to track file2 just inside code, without any updates from styling.
I.e. I would like to update the styling subtree in the code repository, but keep my own version of file2 when I do that (while having file1 synced between styling and code and file3 synced between code and production), so that I can push my own version (v1) of file2 to production later.
Is there any elegant way to do that in git without symlinks or some sophisticated hooks?
Note, I have experimented with:
- .gitignore file2 in the code repository: this does not work, the file is there once I do subtree pull to the styling subtree;
- I have tried to remove file2 from index with git update-index --assume-unchanged styling/file2, but this does not solve my problem;