Reputation: 11639
Create a tmp
branch
Commit some temporary changes
Tag the commit tmptag
x-x-x-y-y <- master \ z <- tmp [tmptag]
Delete the tmp
branch
x-x-x-y-y <- master \ z <- [tmptag]
Now I have a commit, z
that is being held only by a tag tmptag
.
I understand that if you push tmptag
to the remote (either by name or by pushing all tags), commit z
will also be pushed.
Are there any other commands that will push z
to the remote?
Also, if specifically I push all branches, z
will not be pushed, right?
Upvotes: 0
Views: 249
Reputation: 487893
Yes, anything that says ask the other Git to please set some name to point to the commit whose ID is z
will transfer commit z
. For instance:
git push $(git rev-parse tmptag^{}):refs/heads/newbranch
would ask the other Git to create branch newbranch
pointing to the tagged commit. (The ^{}
suffix is required if and only if tmptag
is an annotated tag.) You could also use the raw hash ID, and something other than a branch name, provided the other Git allows you to push to that reference.
Correct: since z
is not reachable from a branch name, it will (at least normally1) not get sent.
1Each Git transport is responsible for collecting objects to send and sending them, and if some transport is weird or careless or something, it could collect up commit z
and send it. The built in push transports (generally invoking git send-pack
with --thin
) won't do that, but it's interesting to consider a case where z
is a base object in a pack, and some deltified object in the same pack also needs to be sent.
Upvotes: 3