You need to push with
git push --all
and if there are new tags, with:
git push --all; git push --tag
Not git push --tags
. --tags
will push all references of tags, not commits on the master branch. I don't know where you have read this advice, but tagging constantly is not really encouraged. Normally you tag when you have a new release of your software. In other words a major milestone. Not for an ordinary commit.
Furthermore I would strongly discourage using the -f
(also known as --force
) flag (fully) automatically. If the repositories are out of sync, it is better not to force your commits over the shared repository. If there are warnings, you must try to resolve them, not overrule these warnings immediately.
General advice is to learn to use a tool instead of following a few steps without realising what is going under the hood.
EDIT:
You probably received an error when you added the tag a second time:
fatal: tag 'foo' already exists
(with foo
the name of the tag). As the statement says, you can't simply tag with the same name twice. git push --tags
commits content up to that tag. Since you assigned the tag with a previous commit, you will push up to that commit, not the latest. You can do a few things:
- Use a different tag (recommended) and push with
git push --tags
;
- Reuse the tag and force tagging
git tag -f -a <tag name> -m <message>
. In that case the old tag is removed. And git push --tags
will work. The problem is that usually tags are used to specify a release. Users might say: aha, the latest release is release-2.3
, I don't have to update the software whereas the new release-2.3
is different from the old one. Annotating with release-2.3-fix0
might make them aware you fixed something.
- Use
git push --all
to push the commit up to the heads of all branches.
Background
You can see your commit graph like:
A -- B -- C -- D
/
<tag>
If you call git push --tag
, it will synchronize A
, B
and C
because that's the last commit under the supervision of <tag>
. If you retag, the tag will be assigned to D
instead.