Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I push a tag for a commit that hasn't been pushed

Tags:

git

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.

like image 205
B Robster Avatar asked Feb 13 '12 17:02

B Robster


2 Answers

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.

like image 66
Cascabel Avatar answered Sep 17 '22 05:09

Cascabel


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.

like image 29
jbowes Avatar answered Sep 19 '22 05:09

jbowes