Kurisu

Kurisu

Using Git to share efficiently libraries between projects

You can go directly to the last paragraph of this post to read about my concern.


I was trying Git submodules then found the above post on Bitbucket, and it fits better my use case. The issue I had with git submodules is that my co-worker could not just pull a parent repository and just work on it without pulling explicitly the submodules also. With subtrees this complexity is gone. I can edit a shared library in any of the projects that are using it and push the commit to its remote repository. Then later in any other project that is using it I can make a pull request to have the library up-to-date. And my co-worker absolutely does not need to be aware of it for it to work.

But now I’m facing a situation that is a bit confusing, at least for me. I have a private repository for a library auth that is basically a set of helpers for authentication. I use it as a git subtree in multiple Elixir /Phoenix projects. So in my last project I have to deal multi-lingual content and I prefer that each application in the project handle the internationalization through its own Gettext backend. Then in my auth library I generate content in multiple languages for that project. But other projects that use this same library don’t necessary need those translations files.

So I’m wondering how to use .gitgnore files so that a parent git repository keep trace of a folder it generated inside a subtree repository, while the subtree repository should ignore that folder when pushing to its own remote repository. The folder in my case is the one that contains the Gettext translations. I can ignore the folder in the subtree repository, but is not it meaning that the main project repository will also follow that rule?

Most Liked

dimitarvp

dimitarvp

That’s exactly my point – now that I reread my post, it’s not clear, sorry. I meant put it on GitHub and don’t put on hex.pm indeed.

dimitarvp

dimitarvp

I’d rather not discuss Git submodules because I heard from several people that they are bad news. I haven’t used them so can’t comment.

In your case you might want to do two things:

  1. Self-host a private Hex repository.
  2. Put your common code there as a library.

I gathered from your post that you don’t want that common code to be public so this likely the solution you are looking for?

dimitarvp

dimitarvp

You are very wrongfully assuming that anyone even cares. :laughing:

Just do it, man. Make a common library, put it up publicly with a short note on what it does and how – don’t need to be detailed. Nobody guarantees any future readers they’ll find anything of use. The amount of abandoned projects out there is gigantic. Just don’t think about it and do it how it’s easiest on you. If that means a public repo, so be it.

Where Next?

Popular General Dev topics Top

Jase
Do they publish their stacks or is it mostly a case of guesswork? Twitter facebook instagram snapchat tiktok google et all. Used to be we...
New
brennan
Trying to understand recursion in Elixir. Sometimes it is simple based on the problem, sometimes it is hard. Any suggestions on how to le...
New
sona11
How can I apply a modified date and time to a variable? This is what I get when I execute the following query in SQL Server Mgmt Studio: ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
PaulMartin
Hey everyone! Do you have any tips or free resources that can help me learn Rspec? Although I know how to write some Rspec, I’m not very...
New
harwind
I’m working on a SQL query for a database containing records of customer transactions. Each transaction has a transaction_id, customer_id...
New
harwind
I’m working on a web application where users can sign up with their email addresses. To ensure data integrity, I want to implement client...
/js
New
harwind
Given an array of integers, find the length of the longest increasing subsequence. A subsequence is a sequence that can be derived from a...
New
harwind
I am working on a Python script, and you encounter an error related to the misuse of lists and tuples. Here’s a simplified version of you...
New
Tazmeen
Hello, I am new to this forum. Not really sure if this topic is relevant for this chat at all. I apologize if its not. I am trying to c...
New

Other popular topics Top

PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New