News for hackers. Stuff that matters.
Re:Show HN: Get rid of Git submodules and never look back (n... by vodou on Monday June 27, 2022 @01:38PM (#31897920)
Are Git submodules really that bad? Really? Maybe it's me that haven't yet discovered their true dark side. They're not perfect, but works well for mid-sized projects at least.
Re:Show HN: Get rid of Git submodules and never look back (n... by witcher_rat on Monday June 27, 2022 @02:18PM (#31898490)
They're better now than they were years ago, but yes they're still bad. And they're still second-class citizens for git commands.

Git has been adding more config settings to try to make it less painful, such as submodule.recurse, but that slows down most git-command significantly and the truth is most repos don't actually need to recurse - they just need the top level. So instead people end up writing aliases to try to handle it, which works ok, but it's brittle and people have to know to do it.

And if you have your repo on GitHub, they don't do some simple things that could have made it easier. For example, they could let the repo owner make the git-clone copy-to-clipboard thing have --recurse-submodules in the command you copy, so that cloning will do the right thing. But they don't. I understand why git itself doesn't want to make such things automatic, but GitHub could do it for at least private enterprise account repos.

BTW, I am _not_ advocating whatever this "Git X-Modules" thing is that the link points to. I have no idea what that is, never used it, and don't plan to.

Re:Show HN: Get rid of Git submodules and never look back (n... by hobo_mark on Monday June 27, 2022 @01:49PM (#31898092)
They're fine, so long as you do not have to fork them. Very often we have to work on multiple submodules in parallel, to make that work we use the same name for all feature branches, then our CI and tools understand that these unrelated branches in unrelated repos actually belong together, but I'd prefer not to have to do that. At least it taught me why so many big companies use monorepos.
Re:Show HN: Get rid of Git submodules and never look back (n... by Groxx on Monday June 27, 2022 @03:12PM (#31899335)
They are implemented in a maximally safe way, which generally means they leave files / folders / etc lying around when you least expect it which goes on to cause later annoyances, because doing otherwise could mean deleting data you didn't know would be deleted.

Say you're git, and someone has a submodule that goes from having:

    sub/
      .gitignore = a/ignored.txt
      a/
        tracked.txt
        ignored.txt
to this, when they `git checkout` some other newer or older or totally-separate-history branch (possibly several layers above this submodule):

    sub/
      b/
        tracked.txt
what do you do with sub/a/ignored.txt? What if the whole submodule was removed?

Git's answer to every single question like this is to either fail to perform the submodule version change, or leave a now-untracked-and-not-ignored sub/a/ignored.txt file in the directory, which leaves you with an un-clean checkout that it'll warn and complain and possibly conflict on.

It's highly unergonomic, but reliably avoids silently doing anything that might cause you to lose data. The awful ergonomics are what people generally hate about it. They'd rather it made some consistent decisions so it Just Worked™ in nearly all cases. But that's not Git-like.

Re:Show HN: Get rid of Git submodules and never look back (n... by Dm_Linov on Monday June 27, 2022 @01:48PM (#31898068)
That's because you haven't had all code messed up when someone pushed in the wrong order :-)
Re:Show HN: Get rid of Git submodules and never look back (n... by Denvercoder9 on Monday June 27, 2022 @02:28PM (#31898631)
How can pushing in the wrong order mess up all code? The worst thing I can imagine is pushing the superproject with a subproject update, but not pushing the subproject. That would end up with an unbuildable commit in the superproject, as you can never check out its associated commit from the subproject, but I don't see how that's close to "messing up all code".
Re:Show HN: Get rid of Git submodules and never look back (n... by Dm_Linov on Monday June 27, 2022 @02:42PM (#31898827)
Re:Show HN: Get rid of Git submodules and never look back (n... by Sirikon on Monday June 27, 2022 @02:53PM (#31899006)
Notice the post is 10 years old and some of the complaints can get solved with the config `submodule.recurse true` https://stackoverflow.com/a/49427199
Re:Show HN: Get rid of Git submodules and never look back (n... by lbhdc on Monday June 27, 2022 @01:56PM (#31898173)
Good question, I was wondering the same. I have never really had an issue with submodules, and I am not sure what the killer feature that this adds over submodules.
Re:Show HN: Get rid of Git submodules and never look back (n... by jayd16 on Monday June 27, 2022 @03:04PM (#31899208)
They're much easier to consume now than they used to be but at the same time they're usually broken by default. Adding them to a project is not seamless or invisible. They do not "just work" with the same commands your team was previously using.

They're still pretty annoying to actively work in.

Re:Show HN: Get rid of Git submodules and never look back (n... by ozim on Monday June 27, 2022 @03:13PM (#31899353)
Maybe that is the problem - you should not use them for stuff that needs to be actively changed all the time.

We keep only DTOs in sub-modules so you really update it if you change property on some communication objects.

This way you also don't want them to be invisible - you really want to see and have people notice this was updated and actively choose what to do with it.

Re:Show HN: Get rid of Git submodules and never look back (n... by antonvs on Monday June 27, 2022 @03:50PM (#31899844)
They have a reputation for being bad, which is enough for a company like the one in the OP to use as a marketing hook.
Re:Show HN: Get rid of Git submodules and never look back (n... by xmorse on Monday June 27, 2022 @01:41PM (#31897973)
The most annoying problem is CI, i cannot even use a private git submodule in Github Actions without creating a personal token, passing it to secret and use some git command
Re:Show HN: Get rid of Git submodules and never look back (n... by dirkt on Monday June 27, 2022 @01:46PM (#31898044)
Which seems more a problem with Github tooling, and less with git submodules.