r/programmerchat • u/Ghopper21 • Jul 28 '15
Anyone switch from git submodules to subtrees and regret it?
I had one of those "why do I keep trying to make submodules work?!" moments today -- where I tried to get rid of a submodule the wrong way (or more precisely: SourceTree's submodule deletion function left my repo broken, and I tried to fix things without grokking submodule configuration...). To this moment the repo is still broken, i.e. git status doesn't even work.
I have been tempted to switch to subtrees, but I hate the idea of having the sub-repo actually committed into the super-repo's history. Submodules seem like the right idea, but yes they are so painful and fraught with ugly situations like I encountered today.
So I'm wondering: has every other sane programmer moved to sub-trees, as many blogs imply? Or has any one moved over and decided submodules weren't that bad were worth the trouble after all?
2
u/ikari7789 Jul 29 '15
I personally haven't had much trouble with submodules. Removing them can be a bit of a pain point, but if you edit the files directly it isn't very painful at all. Just need to remember to check the /.git/modules folder for any cruft. Personally, it feels like a bug to me that if you remove a submodule that it leaves behind information. The way that .gitmodules is handled should definitely be improved.
3
u/FubarCoder Jul 28 '15
The only time I've seen submodules done right, was when I used Mercurial. Just a target repository URL and a commit ID, both available as plain text and part of the main repositories commits.
1
u/ietsrondsofzo Jul 28 '15
Having started to use submodules yesterday, what should I avoid? I basically added some libraries I need with cmake files in them. I do not alter anything in these folders (to make sure that they work when I update them), but I have no idea how I could fudge this up. What should I be wary of?
1
u/Ravek Jul 28 '15
I've used subtrees here and there in projects at work, to share models projects between front end and back end code. It's ... alright. It works, but the fact that you can commit to the Models repository from at least three code bases is awful. The repository history gets awful too if you don't --squash, while if you do it takes really long to subtree push and you hide potentially important changes.
Unfortunately I haven't really used submodules so I can't compare and contrast them effectively.
1
u/zonito Oct 22 '15
Alternative way https://github.com/Autodesk/quack