Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push local branch with same name as remote tag

Tags:

git

git-branch

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

like image 871
youri Avatar asked Feb 21 '12 13:02

youri


People also ask

How push local branch to remote with same name?

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.

Does git push also push tags?

Sharing tags is similar to pushing branches. By default, git push will not push tags. Tags have to be explicitly passed to git push .

What is git Refspec?

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.

How do I remove a remote tag?

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"


3 Answers

The following command should work.

git push origin refs/heads/product-0.2:refs/heads/product-0.2 
like image 72
ralphtheninja Avatar answered Oct 07 '22 18:10

ralphtheninja


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]
like image 62
ecairol Avatar answered Oct 07 '22 19:10

ecairol


If you're trying to push a tag that has the same name of a branch:

git push origin tag myTag
like image 32
Paulo Merson Avatar answered Oct 07 '22 18:10

Paulo Merson