Git submodules and recreate repos with submodules and bad symlinks
OK, I had this problem with my personal repo where I had copied a bunch of courses that meant I was dragging around a lot of git lfs content. The solution was to recreate the repo as a new "richtong" repo, but this meant that all the organizations where I'm working needed major surgery to make it work:
- First is that if you have an old submodule, and want to reuse it's name as of December 2021, you have to do a
git rm richwhich will remove it. But it will still have a copy of all the module information in
./.git/modules/<path to rich/richso you need to do a manual
rm -rfto get rid of it.
- Then you need to
gh repo deletenot that this is a very precipitous action, so you might want to instead just rename the repo
gh repo renameso you still have the old one. Note that I'm using
brew install ghhere which is the github command line and very handy.
- Now you just fork the repo with
gh repo fork email@example.com:richtong/rich --org <the new org>which will do the fork properly
- Now add it as a submodule with
git submodule add firstname.lastname@example.org:<the new org>/richand all is good!
Dangling symlinks and .gitattributes as a symlink
OK, this is a mistake I make a bunch, but if your project is a bunch of submodules, remember that you can't just use a symlink, you will need to do a copy, that's because things like github actions or other uses won't necessarily be nested properly. You can find dangling symlinks easily with pre-commit which will check for these, so make sure you install it.
- A quick check is with
find . -type lto look at our symlinks and see which ones might be missing. And see which point outside the repo.
- One insidious thing I did was to make .gitattributes a symlink, this really causes problems as you can imagine. My bad!