Reputation: 42003
I am using a deploy script that, when I deploy, automatically adds a tag to HEAD (via git tag -f . . .
) indicating the host. The script automatically pushes the tag (via git push --tags
) as well so other users of the repository will know what commit the server is currently running. Generally, I will (manually) push the commit before deploying it, so the tag will match a commit on the remote server, but I'm curious as to what happens if I push a tag for a commit via git push --tags
, where the commit itself hasn't been pushed yet.
Upvotes: 6
Views: 1023
Reputation: 4150
All of the objects needed for that tag will be pushed, but any other references (like HEAD or master) won't be updated. So while the changes you made and your tags will be in the remote repository, anyone who does a pull on master (or whatever branch you're using) won't yet see your commit on their copy of the branch.
Upvotes: 5
Reputation: 496812
Pushing a tag means pushing everything necessary for the tag, just like pushing a branch does. This means pushing the commit it points to, which means pushing the tree for that commit, and the subtrees of that tree, and the blobs in the trees, and the ancestors of that commit, and so on. It just doesn't make any sense to push a ref without pushing the corresponding objects, so Git wouldn't ever do it.
Upvotes: 11