-3

I want every fetch and pull to get tags from origin, replacing local ones if they differ, and delete tags and origin/ branches that are not on origin, so I did this:

git config --global fetch.tags true
git config --global fetch.force true
git config --global fetch.prune true
git config --global fetch.pruneTags true

I still need to type git fetch --force to "clobber" existing tags. The rest works fine. How do I properly add the force flag to git config?

This is in my .gitconfig:

[fetch]
    tags = true
    force = true
    prune = true
    pruneTags = true
H.v.M.
  • 1,348
  • 3
  • 16
  • 42
  • Do you really want your tags to be clobbered? They don’t have a “remote” (local: `refs/remotes`) counterpart. – Guildenstern May 12 '23 at 19:50
  • You say you set things like `fetch.force`. But are those configs a thing? I can’t find that particular one in `man git config`. I think remote-tracking refs just get *clobbered* by default. – Guildenstern May 12 '23 at 20:07
  • @Guildenstern Yes, the only reason I would create a local tag is to immediately push it. – H.v.M. May 15 '23 at 14:10
  • But if you (1) pushed a tag and then (2) someone force-updated it and then (3) you fetched it with clobbering you would end up with their force update and your own tag location would be (eventually) gone. – Guildenstern May 15 '23 at 14:21
  • @Guildenstern That's fine, I keep my local work on branches. Tags are for releases. – H.v.M. May 15 '23 at 14:26

1 Answers1

1

Check the documentation for git config : fetch.force and fetch.tags don't exist.

You can set an alias:

git config --global alias.fetchp "fetch --prune --prune-tags --force --tags"

and use

git fetchp
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • I see, `--tags` is apparently on by default which is why I thought it worked in .gitconfig. This wasn't the case previously as I wouldn't get new tags on commits I'd already fetched. Is there any way to use this alias fetch when pulling in Eclipse? – H.v.M. May 15 '23 at 14:22