# git: tag overwrites, recursing submodules and fetching them

- Link: https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/
- Published: 2025-02-18T07:17:20-08:00
- Author: rich

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](https://stackoverflow.com/questions/58031165/how-to-get-rid-of-would-clobber-existing-tag)
    command. If a tag gets moved to a new commit, then git will refuse to update the
    tags, so you need to do this.

### Share this:

 * [  Mastodon ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=mastodon)
 * [  LinkedIn ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=linkedin)
 * [  Facebook ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=facebook)
 * [  WhatsApp ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=jetpack-whatsapp)
 * [  Email ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?subject=%5BShared%20Post%5D%20git%3A%20tag%20overwrites%2C%20recursing%20submodules%20and%20fetching%20them&body=https%3A%2F%2Ftongfamily.com%2F2025%2F02%2F18%2Fgit-tag-overwrites-recursing-submodules-and-fetching-them%2F&share=email)
 * [More](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/#)

 * [  Telegram ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=telegram)
 * [  Print ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/#print?share=print)
 * [  Pinterest ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=pinterest)
 * [  Tumblr ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=tumblr)
 * [  X ](https://tongfamily.com/2025/02/18/git-tag-overwrites-recursing-submodules-and-fetching-them/?share=twitter)

### Like this:

Like Loading…
