git: tag overwrites, recursing submodules and fetching them

Well this is really advanced stuff, but with large mono repos you really want things to stay in sync, so here are some tricks:

  1. git fetch --all --tags --prune --recurse-submodules. To see how healthy your submodules are, this is very reveraling, it will go down and check every submodule to see if you can fetch things including tags and it will also remove dead branchs that are no longer on the remote origin.
  2. git submodule add -b main git@github.com:richtong/bin. I’ve not used the -b much, but it is critical that each of your development submodules have a tracking branch. The default works if you just want the commit at the time you added the module, but when doing active development, you usually want to pull to the default branch. This makes sure your .gitmodules has this.
  3. git submodule update --init --recursive --remote --checkout well this is another mouthful, but it does a git update to get you all the submodules and check them out. It is really useful when you are starting out and just want a snapshot of everything.
  4. git fetch --tags --force this is a specialty command. If a tag gets moved to a new commit, then git will refuse to update the tags, so you need to do this.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect

Recent posts

Loading Mastodon feed…