I'm trying to push a new local branch product-0.2
to remote where there is already a tag with the same name (but the branch itself does not exist)
git push -v --tags --set-upstream origin product-0.2:product-0.2
Pushing to https://****@github.com/mycompany/product.git
error: src refspec product-0.2 matches more than one.
error: failed to push some refs to 'https://****@github.com/mycompany/product.git'
Same with:
git push origin product-0.2:/refs/heads/product-0.2
Although the other way around it works, e.g. create a branch product-0.1
, commit on it then apply a tag product-0.1
.
Some people work around this by removing the conflicting tag locally, then push the branch, then retrieve the remote tag, but it seems cumbersome and error prone.
How can I create my branch with minimal fuss?
Thanks for your input
In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.
Sharing tags is similar to pushing branches. By default, git push will not push tags. Tags have to be explicitly passed to git push .
A refspec maps a branch in the local repository to a branch in a remote repository. This makes it possible to manage remote branches using local Git commands and to configure some advanced git push and git fetch behavior.
Select and expand the "Tags" tab on the left. Right-Click on the tag you want deleted. Select "Delete YOUR_TAG_NAME" In the verification window, select "Remove Tag From Remotes"
The following command should work.
git push origin refs/heads/product-0.2:refs/heads/product-0.2
Verify what tags are associated with your branch:
git tag
In my case, I had a tag with the same name of the branch. Deleting it worked:
git tag -d [tag-name]
If you're trying to push a tag that has the same name of a branch:
git push origin tag myTag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With