0

At my company we have several git branches from master representing different projects people are working on. I've written a small python file, call it companyLib.py, that appears in each of these branches as it contains commonly used functions that people like to call. As I make updates to companyLib.py, what is an easy way to push the new version to all branches containing the file so that everyone is calling the same, most up-to-date version?

I'm very new to git so it's unclear to me if there is a better way to manage many different branches that all contain one common file and then multiple unique files, where I want to make sure the common file remains consistent across all branches.

Ramsey
  • 9
  • 1
  • 1
    Why don't you extract the common functionality into a separate dependency? – jonrsharpe Jul 27 '16 at 13:08
  • What @jonrsharpe said, have a look at [git submodule](https://git-scm.com/docs/git-submodule) – mash Jul 27 '16 at 13:10
  • @jonrsharpe what would this look like from the users' perspective then? When they check out a branch they are working on with their unique files, they would then check out this "library" submodule containing any common libraries which they could then make calls to? – Ramsey Jul 27 '16 at 13:34
  • Well you can either make it a proper Python dependency they can `pip install`, or just a submodule that gets recursively cloned when they clone the branch. In the second case the submodule points to a specific checkout, so they would need to choose to use a later version. But without quite a lot more information, it's hard to suggest the best approach and the dupe answers your specific question. – jonrsharpe Jul 27 '16 at 13:37
  • @jonrsharpe thanks for the added detail. in order to apply the solution in the dupe, it seems like I would need to know the names of all branches using my library, correct? Making a proper Python dependency might be the way I end up going down the road. – Ramsey Jul 27 '16 at 13:51
  • Git can tell you the branch names too, but yes, you'll need to cherry pick the updates to each branch manually. – jonrsharpe Jul 27 '16 at 13:52

0 Answers0