Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share a file between two repositories using Git & Bitbucket?

Tags:

git

css

bitbucket

I'm building a web-application that has 2 separate components: The front-end that runs in the user's browser (Javascript + Angular) and a back-end REST Api (Python/Django) that runs on my server and feeds data to all the front-ends. The two parts of this app are placed into two separate Git repositories and stored in BitBucket.

The front-end displays the data to the user win a beautiful interface that has lots of nice CSS defined. The back-end sends emails to the users.

I would like the look-and-feel of the emails to exactly match the front-end's display. All the user's interaction should have a uniform presentation. So where/how should I put the CSS such that it is available in both repositories, but I only have to make changes to it in one place??

How do I do this with the tools I'm using: Git & Bitbucket?

like image 887
Saqib Ali Avatar asked Dec 24 '22 05:12

Saqib Ali


2 Answers

I think the CSS should be in a separate "third" project altogether.

Especially since you may even want to reuse the nice CSS for another project, or break the existing projects into more repositories.

So the strategy is:

  1. Create a third repository, e.g. project_css
  2. In both current projects, add references to that repository using git subtree or git submodule.

For example, if you prefer git subtree to have the third project's files part of each of the two existing projects, you can follow a blog/tutorial like this one:

https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/

Whether you use git subtree or git submodule, that depends on the trade-offs you're ok with.

like image 165
Cezary Baginski Avatar answered Jan 18 '23 23:01

Cezary Baginski


write a script in the git pre-commit hook, if the css file is changed, then the script could push the change to BitBucket. See

git help githooks
like image 29
Gregg Avatar answered Jan 18 '23 23:01

Gregg