Search code examples
gitgit-remotegit-configgit-taggit-fork

How to change the default remote where to push tags?


In my repo, the branches usually are specified explicitly what remote should push to (to origin or to fork).

Unfortunately lightweight tags (that I am using just for development, at the moment) don't have the same option.

I've wrongly done git push --tags and all of were copied to the wrong remote. Lot of dirt; so I had to clean up all of them manually.

How to specify what remote the tags should be pushed by default?

NOTE: I usually push lightweight tags on fork, as bookmarks for later reuse (to mark commits that I don't want into a branch).


Solution

  • There is no default remote for tags, only for branches. When you push a tag without specifying the remote, it will go to the default for the branch you are on, aka the remote-tracking branch.

    Use git branch -vv to see the tracking branches for each local branch.

    Use git branch -u <desired upstream remote> [<branchname>] to change them. The last arg is optional and defaults to the same name as the local branch.